WP v3.3 gave us the ability to run wp_enqueue_script in the middle of a page. Ticket 9346
This has made it much easier to include your JS with better granularity (when using shortcodes, at least). Here, jquery will be only included when our shortcode is fired.
function get_slideshow() {
// Do some stuff...
// Load up scripts right from within our shortcode function (requires WP 3.3+)
wp_enqueue_script( 'jquery', array(), null, true );
return;
}
add_shortcode( 'cool_slideshow', 'get_slideshow' );
Related Posts:
- Deactivate JS Script in Plugin Shortcode
- Enqueue style inside shortcode but its loaded at the bottom of page (before footer scripts)
- Is there an earlier hook than login_head or login_enqueue_scripts?
- Can someone please tell me what is wrong with my plugin?
- Calculate price and display on woocommerce product single page under price (simple price, variable price) [closed]
- Best place for short bio,image and button [closed]
- accessing wp.media api from a tinymce plugin
- Redirect to another page using contact form 7? [closed]
- How do I add some javascript validation to the admin interface form’s onsubmit?
- Flipping Book PHP Code? Any experience?
- Executing Javascript in Plugin
- Load CSS files in header of Bones theme?
- Why does my custom plugin only function correctly once per page?
- JS working when used normally but not in wordpress
- front end editor creation for Restropress plug in – displaying information from a WP admin area, on a different URL
- WordPress shortcode plugin not working
- Beginner question: Accessing js script in plugin
- Advanced WordPress plugin activation detection
- How to use template inside plugin shortcode with variables for big HTML code
- Get param from shortcode in plugin function
- shortcode – multiple instances of same parameter name in one shortcode instance
- profile_update hook doesn’t works inside a class
- Function call in wordpress short code handler fails
- strange shortcode error: does shortcodes requires any dependency?
- Loop returns the current page’s permalink and guid instead of the post in the loop
- wp_loaded with static Singleton
- How to use custom Javascript code inside a plugin?
- wp_trash_post hook – problem with page updating if using wp_die
- Why does my jQuery plugin show up as text in WordPress?
- Adding a simple Javascript file with a plugin
- JQuery needs to be defined in , but Gravity Forms is defining it in the
- How to return the values from a row where a value occurs for the first time among the rows available?
- Inserting shortcode in href – any ideas or workarounds?
- Function added to hook “new_to_publish” not executing – custom plugin
- Get Image Having the ID [closed]
- is it possible to hook every page style?
- wp_localize_script not passing the data
- Add the_post_thumbnail_url to a shortcode in function.php
- Comment Approve – Add custom function when comment is approved
- Disable submit button order
- Plugin: Hooking up classes that have their own hooks
- Add action to custom Function
- Get post content from outside the loop with plugin shortcode usability
- Hook for altering the content of all wp mails
- How to rewrite URL and get the values?
- Conditional custom redirect
- Is there a good way to load tiny_mce_popup.js through editor.windowManager.open?
- How to prevent tabs from opening all at once
- Form Plugin for Api Requests which is used via Shortcode
- Hook on creating a menu entry?
- Echo out element to another page.
- Social share buttons text shows up on post excerpts
- Meta slider plugin only works after first refresh – Object has no method ‘flex slider’
- Shortcode and variable
- What hook can I use to modify custom post data before it is displayed on the page?
- How to hook into action/filter call
- how to request a script more than once in wordpress
- Quick press publish post hook
- Prevent plug-in scripts on a specific template?
- using wp_footer hook in a plugin
- Is there any way to inject text onto pages?
- How can I achieve this, using shortcodes
- How to turn off automatic operation for Nivo Slider?
- How to enqueue some javascript source once per page
- Create Short code dynamically
- Get variable value based on string constant
- how to check if a shortcode is used more than one time in the same post
- Dropdown menu on click change
- Adding a Tag Parameter / Filter to My Shortcode
- JS Plugin not executing the js correctly. Trying to make all internal links scroll smoothly
- Call javascript functions from each page
- Filters on the_content with plugins, pages and shortcode
- Which is a better practice when writing shortcodes: pack lots of configuration parameters or just give an id?
- How to deactivate my plugin upon deactivation of NextGen
- Javascript from Easy-Fancybox place into footer
- grab or load text on demand
- How can I replace content on site generated from plugin without changing plugin
- CSS/JS files in WordPress
- How to automatically activate users after registration without activation email?
- Creating a plugin that will display text on every page
- Hooks to run after a core upgrade?
- How do I override all stylesheets and scripts without a plugin
- What’s the default setting for including a in a post
- Rename Smart YouTube’s httpv back to http for all posts
- Wp-minify doesn’t seem to minify my JS code
- Plugin Hook When New Author Added
- Adding custom Field To The Posts Listing
- Hook for plugin to insert into entry-meta
- Plugin Admin panel checkbox unchecked after submit
- uncaught TypeError: Cannot read properties of null (reading ‘classList’) custom plugin
- How do I minify a plugins CSS/JS code?
- Custom Plugin scripts from admin working in frontend
- Code for unique user visit count on every page WordPress
- Elementor Pro display featured image on section -> style -> image using shortcode
- Creating New Dynamic Fields for a Certificate (Number Generation, Code Referencing, and more)
- Help understanding dynamic endpoints based on where a shortcode is used
- Directorist – Dropdown doesn’t open
- Why does “updated_post_meta” did not fire when uploading media other than image?
- Build a must-use plugin that tracks when other plugins are activated or deactivated
- Ajax call not working in wordpress through a plugin