Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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:

wp_enqueue_script('jquery-ui');

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

share|improve this question
add comment

4 Answers

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.

share|improve this answer
    
I already thought this was the case, thanks for the confirmation! –  Menno van leeuwen Nov 30 '13 at 15:59
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.