Support » Plugin: Autoptimize » Uncaught ReferenceError

  • Hello,

    I’ve been using Autoptimize for a while without any problems. But 1-2 weeks ago WooCommerce wouldn’t load product images anymore. In the shop layout the image appears, but when you view single products no image is shown.
    I get the following console error:

    JQMIGRATE: Migrate is installed, version 1.4.1
    autoptimize_697d517
    .php:36 Uncaught ReferenceError: items_in_cart is not defined
        at HTMLDocument.<anonymous> (autoptimize_697d517
    .php:36)
        at i (jquery.js?ver=1.12.4:2)
        at Object.fireWith [as resolveWith] (jquery.js?ver=1.12.4:2)
        at Function.ready (jquery.js?ver=1.12.4:2)
        at HTMLDocument.K (jquery.js?ver=1.12.4:2)

    Enabling the try-catch setting “fixes” this issue, but where does that ReferenceError come from?

Viewing 15 replies - 1 through 15 (of 17 total)
  • Plugin Author Optimizing Matters

    (@optimizingmatters)

    do you have “force JS in head” active @jyourstone? and what about “also aggregate inline JS”?

    I don’t have either of them enabled, because that causes issues with my Divi theme.

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    hmm … would need to have a look at your site, can you share the URL?

    https://www.yourstone-keramik.se

    I also have a staging site where I can disable try/catch if needed.

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    can you try excluding wp-menu-cart-pro/assets/js/wpmenucart-ajax-assist.js or wp-menu-cart-pro/assets/js/ or wp-menu-cart-pro ?

    I tried adding them one by one and all together but it didn’t help.

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    hmmm … do you still have the same JS error on the browser console?

    This is the error I get when excluding those scripts you mentioned:

    JQMIGRATE: Migrate is installed, version 1.4.1
    autoptimize_6663f497049ba64e7a65c01f6b7766b5.php:4 Uncaught ReferenceError: o is not defined
        at n (autoptimize_6663f497049ba64e7a65c01f6b7766b5.php:4)
        at a.fn.init.e.fn.stickThis (autoptimize_6663f497049ba64e7a65c01f6b7766b5.php:4)
        at HTMLDocument.<anonymous> (autoptimize_6663f497049ba64e7a65c01f6b7766b5.php:63)
        at i (jquery.js:2)
        at Object.fireWith [as resolveWith] (jquery.js:2)
        at Function.ready (jquery.js:2)
        at HTMLDocument.K (jquery.js:2)
    Plugin Author Optimizing Matters

    (@optimizingmatters)

    darn ..

    if when enabling try/catch the site works, this means that something in the autoptimized file is breaking. without try/catch execution of the file is halted, try/catch isolates the error and the execution continues.

    now if you don’t want try/catch (and it is better not to have to use try/catch, as there is a performance impact in execution time), then you will indeed have to look for what JS specifically to exclude. sometimes it is obvious (and looking at the source-code and the JS error helps), but sometimes you’ll have to do trial & error I’m afraid, excluding each JS-file separately until you see no error any more. not a fun job, that’s true .. :-/

    Okay, so the problem is with another plugin then? Because if I disable Autoptimize I don’t get any error messages in the console and the images show.

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    Okay, so the problem is with another plugin then? Because if I disable Autoptimize I don’t get any error messages in the console and the images show.

    it’s not that simple; the problem is with the JS from another plugin (or your theme) that breaks when being optimized (which can happen for various reasons). and because of that breakage the execution of the entire autopitmized JS file is halted (which is what browsers do if they encounter an error in a JS-file).

    I’d stay on try/catch for now, I’ll be happy to help you with this once the dust of the 2.2-release settles (lots of support requests now).

    Ok I’ll sit tight for a while, thank you for your help

    Johan Yourstone

    (@jyourstone)

    Hello again,

    I still experience this problem, have any more info for me?
    It seems like my staging site runs fine though, I will continue trouble shooting to see what might cause this.

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    afternoon @jyourstone, I’ll be happy to assist troubleshooting. first of all; the fact you can’t reproduce on staging is weird, first thing would be to find out what the differences are between staging & production?

    Johan Yourstone

    (@jyourstone)

    It’s almost identical and I tried changing the stuff that wasn’t identical, but without any luck.

    I actually ended up disabling Autoptimize. I figure since I can’t optimize CSS because I use Divi, it’s not really worth the trouble finding out what’s causing this issue.

    Thank you for your reply though.

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Uncaught ReferenceError’ is closed to new replies.