• Resolved eltarny

    (@eltarny)


    Hello,

    One of my sites automatically updated to WordPress 5.6, and immediately got destroyed.
    In the browser console multiple “jQuery is not defined” errors appeared.

    After some tests, I deactivated Autoptimize, and the error disappeared and everything was fine.

    I managed to have Autoptimize enabled by unchecking the Aggregate JS-files option.

    The exact same thing happened to all my sites (over 20 sites with various themes and plugins), and the solution of unchecking Aggregate JS-files option worked to all of them.

    Can it be that the new WordPress changed something in the order of the scripts loading and that messes up with the aggregation of the JS files?

Viewing 14 replies - 16 through 29 (of 29 total)
  • Plugin Author Optimizing Matters

    (@optimizingmatters)

    Great! No other regressions (there’s more in 2.8 than just the jQuery fix) to be found Chris?

    I haven’t noticed anything, using only the basic settings for JS, CSS and HTML. No JS/CSS errors or warnings (Chrome + FF), page layout looks good and JS widgets work.

    I tested beta and didn’t get any new errors, but it didn’t switch the jquery.js to jquery.min.js like I expected.
    This was my list before/after I installed beta3:
    wp-includes/js/dist/, wp-includes/js/tinymce/, js/jquery/jquery.js

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    @inflatableoffice what do you have in your Javascript optimization exclusion now?

    Going to test on another site, but here is what I have
    wp-includes/js/dist/, wp-includes/js/tinymce/, js/jquery/jquery.js

    I tested on a different site and it worked fine, so maybe I screwed something up.

    okay i found that if I deactivate and remove autoptimize, then install the beta version I’ve lost all my settings and it has it w/o the .min in it.
    but if I install beta w/o removing the old version, then it works correctly.

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    OK, indeed a bug for new installs, should be fixed now @inflatableoffice would be great if you could re-download the beta-zip & test to confirm when starting from scratch?

    Yep that fixed it.

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    super, thanks for your help inflatableoffice ! ??

    Is there a specific order of operations to force AO2.8 to modify the excluded scripts string to include jquery.min.js? I’ve tried upgrading to 2.8 both before and after upgrading to WP5.6 and in neither case was jquery.min.js appended to my list of excluded scripts.

    * I tried a custom list of scripts which did not have jquery.min.js appended:

    s_sid,smowtion_size,sc_project,WAU_,wau_add,comment-form-quicktags,edToolbar,ch_client,seal.js,jquery.js,reviews.widget,scheduler.widget, wp-content/plugins/revslider/, wp-content/plugins/gravityforms/

    * The following excluded string DID get jquery.min.js added to the end:

    wp-includes/js/dist/, wp-includes/js/tinymce/, js/jquery/jquery.js, wp-content/plugins/revslider/, wp-content/plugins/modal-window/, wp-content/plugins/gravityforms/, wp-content/plugins/UABB/

    * I thought maybe your append search was looking for the inclusion of “js/jquery/jquery.js” and it appears that was a correct assumption. I modified the first completely non-default string to include the old-style WP path to jquery:

    s_sid,smowtion_size,sc_project,WAU_,wau_add,comment-form-quicktags,edToolbar,ch_client,seal.js, js/jquery/jquery.js, reviews.widget,scheduler.widget, wp-content/plugins/gravityforms/, datepicker.min.js

    which was updated to:

    s_sid,smowtion_size,sc_project,WAU_,wau_add,comment-form-quicktags,edToolbar,ch_client,seal.js, js/jquery/jquery.js, reviews.widget,scheduler.widget, wp-content/plugins/gravityforms/, datepicker.min.js, js/jquery/jquery.min.js

    If the conclusion I’ve come to is in fact accurate, I STRONGLY suggest simply setting the minimum requirement of the script exclusion string containing the regex

    /,.*?jquery\.js.*?,/

    have appended “js/jquery/jquery.min.js”, or perhaps more generically “jquery.min.js”

    or maybe you could use a regex of

    /,(.*?)jquery\.js(.*?),/

    replaced with

    “,$1jquery.min.js$2,”

    I think it’s of greater service to the plugin users to be overly-proactive about excluding jquery.min.js with the WP5.6 upgrade. As-is, the addition of jquery.min.js to the exclusion only addresses the WP-specific jquery, but if any site which has modified the _way_ jquery is excluded, the worst-case scenario of the site breaking will happen. Being more fast-and-loose about appending jquery.min.js to the exclusion string has the worst-case scenario of a single JS file being excluded from the autoptimize bundle.

    I’m going to post this reply to the handful of other topics related to the WP5.6 upgrade so that it’s as visible and discoverable as possible to others looking into this.

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    jquery.min.js is only added if jquery.js is already in the exclusion list. if the site worked without excluding the wordpress core native jquery.js, it should work without excluding the wordpress core native jquery.min.js as well.

    Thanks for your quick reply. I’m sorry — that post was a lot of info to include and it was kind of meandering.

    Here’s a more concise explanation: jquery.js IS in the exclusion list, but it has been modified from the default AO string. “js/jquery/jquery” -> “jquery.js”

    I have been able to replicate the following test cases on several sites:

    Test 1
    Excluding WP native jquery from the bundle simply by using the string “jquery.js” without any path info. (I double-checked using Chrome Dev Tools while logged out that the jquery that gets loaded is in fact /wp-includes/js/jquery/jquery.js?ver=1.12.4-wp).

    Upgrade to AO2.8, js/jquery/jquery.min.js is NOT added.

    Test 2
    Change the exact same exclusion list to reference jquery using the string “js/jquery/jquery.js” WITH path info.

    Upgrade to AO2.8, js/jquery/jquery.min.js IS added.

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    I’m looking at this from the default AO config point of view, which has js/jquery/jquery.js excluded by default. If that is found, js/jquery/jquery.min.js indeed is added at upgrade time.

    If for some reason someone changed the exclusion to just jquery.js then indeed jquery.min.js is not added, but at that point we indeed are not in the “default configuration” view any more and the automatic exclusion update does not apply.

Viewing 14 replies - 16 through 29 (of 29 total)
  • The topic ‘jQuery is not defined after updating to WordPress 5.6’ is closed to new replies.