Why is wp_enqueue_script not loading included jquery ui scripts?

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.

Read More

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?

Related posts

Leave a Reply

2 comments

  1. 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:

    1. There’s no need to add array( 'jquery' ) as $dependency argument for jquery-ui-core, as Chip shows us in this core reference
    2. As Manny stated, you need to add every effect/plugin by itself, like for e.g. 'jquery-effects-fold', 'jquery-ui-resizable' or 'jquery-effects-explode'.
    3. The example is right, but missing the (possibly) needed plugins

      wp_enqueue_script( 'jquery' );
      wp_enqueue_script( 'jquery-ui-core' );
      
  2. 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:

    wp_enqueue_script('jquery-ui-sortable'); //load sortable
    wp_enqueue_script('jquery-ui-tabs'); //load tabs
    

    A complete list of what you can load is here