Use wp_enqueue_script
in your shortcode handler, in WordPress >= 3.3 it will be added to the page in the wp_footer
action. Pass any data you need from PHP to JavaScript via wp_localize_script
.
Related Posts:
- How to get a jQuery script to run on a page?
- How to properly add Bootstrap and JQuery Javascripts?
- Correct Method to run scripts with dependencies without enqueue?
- How to prevent wordpress from loading old versions of jquery in wp_head();?
- Move WordPress native javascript to bottom of page?
- Add custom shortcode button to Editor
- RequireJS in custom theme. Working Example
- Asynchronous Javascript Loaders
- wp_enqueuescript won’t load in footer even with true value set?
- How wp_enqueue_script works?
- WordPress Script Loading/Unloading — wp_deregister_script(‘jquery’)
- How do I get my page to load the jQuery UI Effects library?
- Script won’t execute in the media manager
- How to add unique image class to WordPress
- Enqueuing javascript files
- Creating multiple enclosing shortcodes and fixing JS issues on click
- Searching multiple tags and adding jQuery dependant script onto page template?
- Plugin Scripts no loading on options page
- How to enque js script in footer that are not in .js file?
- Loading scripts on a single page plants the script in the footer
- Nested Gallery Shortcode INTERMITTENTLY working
- Disable Cloudflare Rocket Loader for jQuery javascript and make it load first
- Using WP functions inside javascript
- Including Older Version of jQuery for IE7/IE8
- How To Include JavaScript Files Only In Single Posts?
- How to make JQuery load on top of head tag before everything
- JavaScript code do not works on online server
- Bootstrap with separate js File
- JQuery Login Dropdown not functioning in theme
- How to add JS snippet before closing tag?
- Enqueue javascript that inserts custom php widget into jQuery-constructed div
- How to deregister scripts all at once
- Uncaught TypeError: undefined is not a function (shortcode-box)
- How to Run a jQuery Script after a Javascript Script has Finished in WordPress
- javascript not loading in wordpress
- bootstrap-slider.js by seiyria not working in wordpress
- How to set time delay in javascript
- JavaScript: filter() for Objects
- JavaScript runtime error: ‘$’ is undefined
- How to get client’s IP address using JavaScript?
- Simple throttle in JavaScript
- Enable & Disable a Div and its elements in Javascript
- The ‘describe’ keyword in javascript
- force enqueue script to be first in order of prominence
- Using get_option() in JavaScript
- Make jQuery library load before plugin files
- Add tinymce buttons to caption textarea in media uploader
- How to handle multiple instance of “send_to_editor” js function
- wp_register_script multiple identifiers?
- How do I enqueue(or delay loading of) tags in individual page posts?
- Execution of JavaScript on save post
- Is placing stuff in page text edit window bad form?
- wp_enqueue_script adds only the first script
- Add colorpicker to featured image
- Auto-detect javascript errors and warn theme user
- combining js scripts from a js newb [closed]
- Heartbeat API: How to access data already enqueued?
- Implementing lazy loading in homepage posts instead of pagination
- Why won’t my scripts load?
- Is it necessary to enqueue jquery?
- jQuery not available to other scripts
- WordPress Ajax problem with undefined url
- Move jQuery to the bottom of the page whilst keeping the WordPress jQuery
- Using bootstrap-slider and bootstrap-switch in wordpress admin panel
- WordPress jquery files not being enqueued
- WP UI style within shortcode – Any Suggestions?
- Javascript stopped working [closed]
- Why is my WordPress loading old version of JQuery?
- Why load JS through the CMS framework? [duplicate]
- Unexpected script loading order
- url – ajax loaded but no JS
- Why should I deregister jquery?
- jQuery will not work on page from snippet or file
- How to keep HTML form field that is conditional hidden with javasript hidden after page reload?
- Accessing javascript in multiple files [closed]
- Issues loading Jquery on WordPress website
- Script not loading when depending on jQuery
- Custom AJAX form not working async
- jQuery is not defined, working on local server but not online
- WP_ENQUEUE not working with Foundation 5
- Parse wordpress blog data using json api and ajax
- Problem adding MP3 attachments to a jPlayer playlist
- wp_enqueue_script jquery and jquery ui not working
- wp_enqueue_script calling jQuery at different times for different browsers?
- A carousel slideshow plugin in JavaScript
- wp_enqueue_script JS code runs too late (after user begins interacting)
- Get localize of a loaded javascript
- Get with jQuery the value of an ACF field
- JS working when used normally but not in wordpress
- Get ajaxForm response value
- Adding scripts before plugins scripts
- jQuery search function not running in WordPress but running locally (fiddle)
- Masonry – Can’t Find Variable imagesLoaded
- Can’t seem to get JQuery working (wordpress plugin)
- Ajax Request with jQuery not happening
- How to make jQuery load AFTER plugin’s script?
- Can’t get jQuery to enqueue into post edit script
- Carousel Hover Image
- How to Javascript/jQuery
- Uncaught ReferenceError: tippy is not defined