Title: Uncaught ReferenceError
Last modified: June 21, 2017

---

# Uncaught ReferenceError

 *  [Johan Yourstone](https://wordpress.org/support/users/jyourstone/)
 * (@jyourstone)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/uncaught-referenceerror-9/)
 * 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)

1 [2](https://wordpress.org/support/topic/uncaught-referenceerror-9/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/uncaught-referenceerror-9/page/2/?output_format=md)

 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/uncaught-referenceerror-9/#post-9248525)
 * do you have “force JS in head” active [@jyourstone](https://wordpress.org/support/users/jyourstone/)?
   and what about “also aggregate inline JS”?
 *  Thread Starter [Johan Yourstone](https://wordpress.org/support/users/jyourstone/)
 * (@jyourstone)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/uncaught-referenceerror-9/#post-9248528)
 * I don’t have either of them enabled, because that causes issues with my Divi 
   theme.
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/uncaught-referenceerror-9/#post-9248542)
 * hmm … would need to have a look at your site, can you share the URL?
 *  Thread Starter [Johan Yourstone](https://wordpress.org/support/users/jyourstone/)
 * (@jyourstone)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/uncaught-referenceerror-9/#post-9248554)
 * [https://www.yourstone-keramik.se](https://www.yourstone-keramik.se)
 * I also have a staging site where I can disable try/catch if needed.
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/uncaught-referenceerror-9/#post-9248933)
 * 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` ?
 *  Thread Starter [Johan Yourstone](https://wordpress.org/support/users/jyourstone/)
 * (@jyourstone)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/uncaught-referenceerror-9/#post-9251513)
 * I tried adding them one by one and all together but it didn’t help.
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/uncaught-referenceerror-9/#post-9251658)
 * hmmm … do you still have the same JS error on the browser console?
 *  Thread Starter [Johan Yourstone](https://wordpress.org/support/users/jyourstone/)
 * (@jyourstone)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/uncaught-referenceerror-9/#post-9251666)
 * 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](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/uncaught-referenceerror-9/#post-9251899)
 * 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 .. :-/
 *  Thread Starter [Johan Yourstone](https://wordpress.org/support/users/jyourstone/)
 * (@jyourstone)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/uncaught-referenceerror-9/#post-9252034)
 * 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](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/uncaught-referenceerror-9/#post-9252527)
 * > 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).
 *  Thread Starter [Johan Yourstone](https://wordpress.org/support/users/jyourstone/)
 * (@jyourstone)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/uncaught-referenceerror-9/#post-9252671)
 * Ok I’ll sit tight for a while, thank you for your help
 *  Thread Starter [Johan Yourstone](https://wordpress.org/support/users/jyourstone/)
 * (@jyourstone)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/uncaught-referenceerror-9/#post-9607592)
 * 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](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/uncaught-referenceerror-9/#post-9607654)
 * afternoon [@jyourstone](https://wordpress.org/support/users/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?
 *  Thread Starter [Johan Yourstone](https://wordpress.org/support/users/jyourstone/)
 * (@jyourstone)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/uncaught-referenceerror-9/#post-9608178)
 * 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)

1 [2](https://wordpress.org/support/topic/uncaught-referenceerror-9/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/uncaught-referenceerror-9/page/2/?output_format=md)

The topic ‘Uncaught ReferenceError’ is closed to new replies.

 * ![](https://ps.w.org/autoptimize/assets/icon-256X256.png?rev=2211608)
 * [Autoptimize](https://wordpress.org/plugins/autoptimize/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/autoptimize/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/autoptimize/)
 * [Active Topics](https://wordpress.org/support/plugin/autoptimize/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/autoptimize/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/autoptimize/reviews/)

 * 17 replies
 * 2 participants
 * Last reply from: [Johan Yourstone](https://wordpress.org/support/users/jyourstone/)
 * Last activity: [8 years, 7 months ago](https://wordpress.org/support/topic/uncaught-referenceerror-9/page/2/#post-9608798)
 * Status: not resolved