0

While trying to fix the Render-Blocking issue on my website, I ran into a problem with the W3 Total Cache plugin on its Minify settings page.

The two buttons to add JS (Add a script) and CSS (Add a style sheet) are not working, nothing happens after clicking them.

The cause of the issue can be seen in the browser console error message (WP uses jQuery 1.12.4, W3TC requires jQuery <1.9)

Related question jQuery(...).live is not a function

options.js?ver=0.9.6:324 
Uncaught TypeError: jQuery(...).live is not a function
    at HTMLDocument.<anonymous> (options.js?ver=0.9.6:324)
    at i (load-scripts.php?c=0&load[]=jquery-core,utils&ver=4.8.5:2)
    at Object.fireWith [as resolveWith] (load-scripts.php?c=0&load[]=jquery-core,utils&ver=4.8.5:2)
    at Function.ready (load-scripts.php?c=0&load[]=jquery-core,utils&ver=4.8.5:2)
    at HTMLDocument.K (load-scripts.php?c=0&load[]=jquery-core,utils&ver=4.8.5:2)

options.js is the file causing the issue on lines like this (jQuery(...).live has been deprecated since jQuery 1.9):

jQuery('#pgcache__reject__logged_roles').live('click', function(){
        w3tc_input_enable('#pgcache_reject_roles input[type=checkbox]', jQuery('#pgcache__reject__logged_roles:checked').size());
    });

What would be the most acceptable and cleanest way to resolve the issue:

  • Is there an updated W3TC plugin?
  • Is there a clean way to make W3TC use different jQuery version than WP?
  • Using a jQuery plugin like jQuery Migrate?
  • Manually changing the affected lines?

JS minify settings

  • The object reference for the jQuery included with WordPress is jQuery, not the default $. – Milo Feb 4 '18 at 2:14
  • The code example in the question already uses jQuery – Peter Gerhat Feb 4 '18 at 9:40
  • Your edit has added new information, I pointed that out as I noticed you were loading your own version of jQuery, which you’ve now removed. – Milo Feb 4 '18 at 13:55
  • You're right, but that's the jQuery included with the theme. After realizing that the error has to do with WP-Admin (the theme doesn't get loaded), I deleted the code segment. The jQuery 1.12.4 gets loaded as part of WP-Includes (/www/wp-includes/js/jquery/jquery.js) – Peter Gerhat Feb 4 '18 at 14:24
0

WP Admin normally loads the migrate script automatically. Apparently your theme dequeued/deregistered that script (too).

The upcoming release fixes issues with calls to the deprecated live() function in cases like yours where the migrate script doesn't work or is not loaded.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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