Add a Script button in W3 Total Cache plugin not working due to conflicting jQuery version

admin2025-01-07  4

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?

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?

Share Improve this question edited Feb 4, 2018 at 14:30 Peter Gerhat asked Feb 3, 2018 at 23:01 Peter GerhatPeter Gerhat 1114 bronze badges 4
  • The object reference for the jQuery included with WordPress is jQuery, not the default $. – Milo Commented Feb 4, 2018 at 2:14
  • The code example in the question already uses jQuery – Peter Gerhat Commented Feb 4, 2018 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 Commented Feb 4, 2018 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 Commented Feb 4, 2018 at 14:24
Add a comment  | 

1 Answer 1

Reset to default 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.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736261414a740.html

最新回复(0)