Support » Developing with WordPress » wp_enqueue_script ignoring jquery-ui packages

  • I am loading js scripts for a plugin I have, and in about 2% of my installs, the jquery-ui packages are getting ignored and not loaded. Here is an example of the function I am hooking to:

    public function addAdminScripts() {
    	    // jquery ui
    		wp_enqueue_script('jquery-validate-js',BREW_MODULES_URL.'Core/assets/js/jquery.validate.min.js', array('jquery'), BREW_ASSET_VERSION);
            wp_enqueue_script('ib-jquery-serialize-object', BREW_MODULES_URL.'Core/assets/third-party/jquery-serialize-object/jquery.serialize-object.js', array('jquery'), BREW_ASSET_VERSION);
            wp_enqueue_script('ib-core-js', BREW_MODULES_URL.'Core/assets/js/core.js',array('jquery'), BREW_ASSET_VERSION);
            wp_enqueue_script('ib-tabs-jquery-js', BREW_MODULES_URL.'Core/assets/js/ib-tabs.jquery.js', array('jquery'), BREW_ASSET_VERSION);
            wp_enqueue_script('ib-form-validator', BREW_MODULES_URL.'Core/assets/js/ib-form-validation.js',array('jquery'), BREW_ASSET_VERSION, true );
            wp_enqueue_script('ib-ajax-handler-js', BREW_MODULES_URL.'Core/assets/js/ib-ajax-handler.js',array('jquery','ib-form-validator'), BREW_ASSET_VERSION, true );
            wp_enqueue_script('ib-confirm-js', BREW_MODULES_URL.'Core/assets/js/jquery.confirm.js', array('jquery'), BREW_ASSET_VERSION);
            wp_enqueue_script('clipboard-min-js', BREW_MODULES_URL.'Core/assets/js/clipboard.min.js', array('jquery'), BREW_ASSET_VERSION);
            wp_enqueue_script('jquery-tipsy-js', BREW_MODULES_URL.'Core/assets/js/jquery.tipsy.js', array('jquery'), BREW_ASSET_VERSION);
    		// data tables
            wp_enqueue_script('data-tables-js',BREW_MODULES_URL.'Core/assets/third-party/DataTables-1.10.12/jquery.dataTables.js', array('jquery'), BREW_ASSET_VERSION);
            wp_enqueue_script('ib-datatables-col-reorder', BREW_MODULES_URL.'Core/assets/third-party/DataTables-1.10.12/dataTables.colReorder.js', array('data-tables-js'), BREW_ASSET_VERSION);
    		// resize
            wp_enqueue_script('ib-col-resize', BREW_MODULES_URL.'Core/assets/third-party/jquery-colresize/colResizable-1.6.js', array('jquery'), BREW_ASSET_VERSION);
                'ib-ajax-handler-js', 'ibAjax',
                    'ajaxurl' => admin_url('admin-ajax.php'),
            if(@$_GET['page'] == "inboundbrew"){
    	        wp_enqueue_script('ib-wizzard-js', BREW_MODULES_URL.'Core/assets/js/ib-wizzard.js',array('jquery'), BREW_ASSET_VERSION, true );

    All of the custom scripts that are unique to my plugin are getting loaded just fine. I can debug and echo in that function and it is getting called appropriately.

    In most of my clients and others installs, the “load-scripts.php” call includes the jquery-ui packages just fine. However, in one my devs local env and one of my clients sites that I have found, “load-scripts.php” does not have the jquery-ui components listed as arguments.

    I have already deactivated all other plugins and even tried different themes to rule that out. I am at a total loss.


Viewing 1 replies (of 1 total)
  • Moderator bcworkz


    In those few installations, jquery-ui consistently fails to load, yes? Intermittent failures would be even more trying to track down. There must be something about those individual installations. Check .htaccess files for anything that could prevent certain files from being accessed. Sometimes security rules intended for something unrelated inadvertently prevent particular files from being accessed.

    Check the wp-config file for definitions like ‘SCRIPT_DEBUG’ that would cause non-minified versions to be loaded. If these happen to be missing or are corrupt, loading can fail while loading minified versions work fine.

    Possibly even the minified versions normally loaded might be missing or corrupt. Try reinstalling all files in the /jquery/ folder. Also confirm permissions are correct on all such files and folders. Permissions on the /ui/ folder would be particularly suspect based on your problem description.

    Probably not the problem and more just FYI, you shouldn’t need to enqueue every module separately. Merely specifying a module as a dependency of one of your scripts should cause all registered dependencies to be automatically loaded in the proper order without your specific code doing so. For example, let’s say ‘ib-confirm-js’ depends on ‘jquery-ui-accordion’ to function properly. Simply specifying ['jquery-ui-accordion'] as the dependency argument should cause all of its dependencies to be loaded as well — ‘jquery-ui-core’ and ‘jquery’. It wouldn’t hurt to list these in your dependency array too, but it’s not necessary.

    It shouldn’t even hurt to enqueue these as well, but it’s not necessary. What will get you in trouble though is if you enqueue a module that conflicts with another parallel module loaded through dependencies. For instance if jquery-ui-core is dependent on jquery 1.12 but you inadvertently enqueued jquery 1.10, or even the same version from a different source, you will have troubles.

    It’s also conceivable some other code had de-registered a module for some reason, causing all referenced dependents on it to fail. It seems unlikely since you’ve tried no plugins and different themes, but it could be code within your own modules. Sometimes code can sneak into our own work without our explicit knowledge, especially when reusing code from other projects.

    You could try checking the dependency properties when “wp_print_scripts” action fires. The UI modules should be in the $queue and $to_do properties. If not, check the same after all “wp_enqueue_scripts” callbacks have run. The $queue versions should match. Whether they do or not tells you to debug forwards or backwards. It will be tedious, but you can eventually find where things go awry by checking values at certain points. Zero in until the problem is found. The process is essentially a binary search algorithm.

Viewing 1 replies (of 1 total)
  • The topic ‘wp_enqueue_script ignoring jquery-ui packages’ is closed to new replies.