0
votes
1answer
41 views

Enqueue scripts based on options

What is the best method to enqueue scripts based on options I have? Let's say I have 50 options and for each I need to enqueue a script(some of them might repeat.). Can I have any ...
4
votes
3answers
235 views

Best Practices for Seperating jQuery from HTML/PHP

I am creating several jQuery scripts to help validate forms before they are submitted. I have read that it is best to always separate jQuery scripts into a separate file so that you can load the ...
0
votes
3answers
1k views

Loading Modernizr (or other JavaScript libraries) for use in a plugin

Download a copy of Modernizr, put it in your plugin’s directory and simply enqueue the script whenever needed. Done. The problem is that Modernizr may already be loaded by another plugin. You ...
3
votes
1answer
99 views

Hyphens vs. periods in the script slug in wp_register_script?

I have seen script and style handles written in two different ways in wp_register_script and wp_enqueue_script (the same applies to wp_register_style and wp_enqueue_style): wp_register_script( ...
1
vote
1answer
175 views

Is it recommended to pass some data to scripts in `wp_enqueue_scripts`?

I have on many occasions used wp_enqueue_script to pass some 'query variables' to scripts like this: function my_enqueue_scripts(){ $tempurl = urlencode( get_bloginfo( 'template_url' ) ); ...
20
votes
6answers
6k views

Conditionally Loading JavaScript/CSS for Shortcodes

I released a plugin that creates a shortcode and requires a JavaScript file and a CSS file to load on any page that contains that shortcode. I could just make the script/style load on all pages, but ...