Support » Plugin: Autoptimize » Uncaught ReferenceError

  • Resolved john53

    (@john53)


    Hi

    Thank you for producing such a great plugin.

    I am using cloudflare and cache everything using page rules

    I am using the Astra theme

    When using chrome/lighthouse to check performance on mobile using simulated fast 3G I get the following critical browser error “Uncaught ReferenceError: jQuery is not defined at (index):124”

    The part highlighted on line 124 is:-
    “}(jQuery);</script> <script type=”text/javascript” defer src=”https://www.primaflorafloristaccrington.co.uk/wp-content/cache/autoptimize/js/autoptimize_a9716657f435ceeb71ce48bc7c0d4787.js”></script></body></html>”

    I believe that caching everything is causing the problem but is there any way that you can eliminate this problem using addition css code or something please as the performance gain from caching everything is significant and I don’t want to lose it.

    Thank you
    Best regards
    John

    The page I need help with: [log in to see the link]

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

    (@optimizingmatters)

    Would love to help, but can’t access the page John so have to remain somewhat generic; “jQuery is not defined” is usually caused by either jQuery not being excluded from JS optimization in Autoptimize or because you’re asyncing/ deferring jQuery (possibly using the Async JavaScript plugin). You’ll have to leave jQuery be, so make sure js/jquery/jquery.js is in the JS optimization exclusion list and make sure it is not asynced/ deferred.

    hope this helps,
    frank

    Hi Frank
    Thank you very much for the quick response.

    You were absolutely right. Excluding jquery from async JavaScript plugin got rid of the error but my google compare my mobile website score has gone from 2 seconds to 2.6 seconds.

    The error doesn’t seem to have any effect on the front end of my website. Is there any real downside to ignoring the error in order to get a faster website?

    I don’t know why access us being blocked but if you give me an up address I will whitelist it.

    Thanks for your help

    Best regards

    John

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    If all works (for all visitor on all browsers/ devices) despite the error, then you could leave as is yes 🙂

    john53

    (@john53)

    Hi Frank

    Thank you for telling me to check all browsers before leaving the error in place. Although everything was perfect on chrome, microsoft edge and firefox did have problems loading all of the content.

    So I have have excluded jQuery from the Async Javascript plugin.

    Chrome Lighthouse analysis suggests enabling text compression on jQuery and Autoptimize :-

    “Opportunities
    These optimizations can speed up your page load.
    Opportunity
    Estimated Savings
    1
    Enable text compression
    1.35 s
    Text-based resources should be served with compression (gzip, deflate or brotli) to minimize total network bytes. Learn more.
    URL
    Size (KB)
    Potential Savings (KB)
    https://www.primaflorafloristaccrington.co.uk
    159 KB
    130 KB
    …jquery/jquery.js(www.primaflorafloristaccrington.co.uk)
    95 KB
    62 KB
    …js/autoptimize_a971665….js(www.primaflorafloristaccrington.co.uk)
    54 KB
    37 KB
    2
    Eliminate render-blocking resources
    0.7 s
    Resources are blocking the first paint of your page. Consider delivering critical JS/CSS inline and deferring all non-critical JS/styles. Learn more.
    URL
    Size (KB)
    Potential Savings (ms)
    …jquery/jquery.js(www.primaflorafloristaccrington.co.uk)
    95 KB
    600 ms”

    Could you please let me know if there is an easy way to do this?

    Thanks once again.

    Best regards

    John

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    Text compression is normally a configuration on webserver-level, but for the autoptimized files you could alternatively disable the “static files”-option in which case the files will be served compressed through PHP.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.