AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Enqueue javascript wordpress theme1/1/2024 Enqueueing Basics With wp_enqueue_scripts The way to make this happen is to register the script first, and only actually enqueue it when the shortcode is shown (suggested reading: The Ultimate Guide to WordPress Shortcodes). For example: If you’re building a custom gallery shortcode that uses Javascript you only actually need to load the JS when the shortcode is used – probably not on every page. ![]() Sometimes you’ll want to let WordPress know about an asset, but you may not want to use it on every page. ![]() The reason for having two steps has to do with modularity. First you register it – tell WordPress it’s there – and then you actually enqueue it, which eventually outputs it into the header or just before the closing body tag. There are two steps taken when enqueueing a script or a style.
0 Comments
Read More
Leave a Reply. |