Using WordPress 3.4.2, the wp_enqueue_script documentation seems to indicate that jQuery UI libraries can be loaded simply by referencing their handles. I have the following code with no prior wp_register_script():
wp_enqueue_script('jquery');
wp_enqueue_script('jquery-ui-core');
The enqueue for ‘jquery’ works fine, but the enqueue for ‘jquery-ui-core’ isn’t working.
I realize that I can register and load script explicitly using Google CDN (or make explicit references to library elements in WordPress install) … but again documentation makes me think I shouldn’t have to do this w/ WordPress current version.
Anyone know why this doesn’t work?
I guess you have to really read the Codex about
wp_enqueue_script()
again and then dig into jQuery a little bit more. jQuery UI is a dependency of jQuery (which means it depends on having jQuery loaded). So you need to load jQuery first, before loading jQuery UI (or jQuery UI Mobile).Edit as per @ChipBennet and @MannyFleurmond comments below:
array( 'jquery' )
as$dependency
argument forjquery-ui-core
, as Chip shows us in this core reference'jquery-effects-fold'
,'jquery-ui-resizable'
or'jquery-effects-explode'
.The example is right, but missing the (possibly) needed plugins
Loading jquery-ui just loads the core of the UI plugins. If you want to load individual plugins, you’ll have to load the separately:
A complete list of what you can load is here