Include jQuery UI as a whole

Is it possible to include jQuery UI as a whole instead of:

wp_enqueue_script('jquery-ui-core');
wp_enqueue_script('jquery-effects-core');
// a lot of other jquery ui imports....

I’ve searched in the codex and was able to find the full list of included scripts, but could not find a way to include the full jQuery UI version as one import like:

Read More
wp_enqueue_script('jquery-ui');

Sources:
http://codex.wordpress.org/Function_Reference/wp_enqueue_script

Related posts

4 comments

  1. If you take a look at registrations in source there is no alias to load all of jQuery UI in bulk available and WP core itself uses pieces as dependencies individually.

    You could create and use such alias yourself (registered script handle with no URL and all of needed scripts as dependencies), but it might be overkill – there are a lot of scripts there to load.

  2. You can filter out all jQuery UI scripts from the global $wp_scripts:

    function wpse124959_wp_scripts_filter() {
        global $wp_scripts;
            foreach ($wp_scripts->registered as $reg) {
                if ( preg_match('/^jquery-ui/', $reg->handle ) )
                    $script_hs[ $reg->handle ] = $reg->src;
            }
            print_r( $script_hs );
    }
    add_filter( 'wp_head', 'wpse124959_wp_scripts_filter' );
    

    This could theoretically be used to enqueue them or build the alias @rarst suggested.

  3. Just include the pieces you actually need. It will handle the dependencies for you.

    For example, if you needed jquery-ui-dialog, then you can just enqueue that one and it will then go and automatically add jquery-ui-resizable, jquery-ui-draggable, jquery-ui-button, jquery-ui-position, jquery-ui-core, jquery-ui-mouse, jquery-ui-widget, and jquery all by itself.

  4. You should enqueue just the scripts you need, and it will add in the script dependencies. You don’t need to worry about picking which ones to enqueue. For example, if you want to include the scripts required for the Accordion widget, just add the following snippet and it will load all the dependencies too (jQuery, jQuery-UI core, jQuery widget).

    wp_enqueue_script('jquery-ui-accordion');
    

    If what you want to do is load them all as a single minified resource, install Use Google Downloads plugin. It will load the appropriate version from the Google CDN, minified and served with gzip compression and a long expiry time.

Comments are closed.