• Resolved Mr. W

    (@gabriel-winnberg)


    Hello,

    Smart Variations stops working when Autoptimize is minifying JS. A number of different behaviors and errors depending on Autoptimize settings. I’ve excluded all js from /wp-content/plugins/smart-variations-images/assets/js but that doesn’t resolv it. I get these errors:

    Uncaught ReferenceError: jQuery is not defined(anonymous function) @ jquery.ez-plus.min.js:2
    Uncaught ReferenceError: jQuery is not defined(anonymous function) @ svi-frontend.min.js:1

    The swatches show, it seems to be loading an image (there is a pause when the swatches gray out) but no image is displayed.

    It starts working again when I switch off JS optimization.

    What should I try next?

Viewing 15 replies - 1 through 15 (of 16 total)
  • What should I try next?

    add js/jquery/jquery.js to the JS optimization exclusions gabriel πŸ™‚

    frank

    Thread Starter Mr. W

    (@gabriel-winnberg)

    Hey Frank!

    Thanks, still doesn’t work. I excluded these:

    js/jquery/jquery.js
    jquery.ez-plus.js
    jquery.ez-plus.min.js
    svi-admin-settings.js
    svi-admin-settings.min.js
    svi-frontend.js
    svi-frontend.min.js

    … and tried all combinations of JS exclusion options:

    – ​Force JavaScript in head
    – ​Add try-catch wrapping
    – Aggregate inline JS

    Should there be file paths in the exclusion list like js/jquery/jquery.js?

    Cheers,
    Gabriel

    • This reply was modified 9 years, 6 months ago by Mr. W.
    Thread Starter Mr. W

    (@gabriel-winnberg)

    Oh, BTW from https://sv.wordpress.org/plugins/autoptimize/faq/:

    Why is jquery.js not optimized
    Starting from AO 2.1 WordPress core’s jquery.js is not optimized for the simple reason a lot of popular plugins inject inline JS that is not aggregated either (due to possible cache size issues with unique code in inline JS) which relies on jquery being available, so excluding jquery.js ensures that most sites will work out of the box. If you want optimize jquery as well, you can remove it from the JS optimization exclusion-list (you might have to enable “also aggregate inline JS” as well or switch to “force JS in head”).”

    weird, as

    Uncaught ReferenceError: jQuery is not defined(anonymous function)

    indicates jquery is not available when jquery.ez-plus.min.js and svi-frontend.min.js are loaded. but if jquery, jquery.ez-plus.min.js and svi-frontend.min.js all are excluded, then this might not be related to autoptimize …

    anyways; hard to troubleshoot further without a URL, could you share that?

    (I know that jquery is excluded by default since 2.1 -as i’m ao’s developer-, but you could have changed that setting, couldn’t you? πŸ˜‰ )

    Thread Starter Mr. W

    (@gabriel-winnberg)

    Haha ok, I completely missed that! πŸ˜‰
    I’m talking to the right guy then …

    I have changed the setting back and forth a number of times.

    It’s a development site, I’ll PM you.

    Plugin Author RosendoLabs

    (@drosendo)

    HI,

    So, are thing solved?

    no, not yet David.

    what is weird is that even when aggregating all JS code and loading it at the very end of the HTML (or when not aggregating inline JS and excluding jquery.js and all JS of your plugin), the code is complaining about $container.imagesLoaded(…).progress not being a function, although imagesLoaded.pgkd.min.js is present and loaded before the JS that is throwing the error …

    is imagesLoaded(…).progress part of imagesLoaded.pgkd.min.js which you load from cdnjs.cloudflare.com? is there any specific reason you’re not including that file in the local JS?

    frank

    Plugin Author RosendoLabs

    (@drosendo)

    Hi,

    No specific reason, just less files. πŸ™‚ Maybe I should include them as fallback.

    well … my gut feeling says loading that file locally would solve the autoptimization-problems, so I think Gabriel would be very interested πŸ˜‰

    Plugin Author RosendoLabs

    (@drosendo)

    It’s the first issue im experiencing of this kind. It’s just strange being that.
    User has to dequeue the imagesLoaded and use a local file for debugging purpose. If it works then, I believe I shall add the files to the plugin.

    THanks,
    David

    so Gabriel, are you up for that? πŸ™‚

    Thread Starter Mr. W

    (@gabriel-winnberg)

    I would, Frank. πŸ™‚

    I’m no specialist on CDNs, but could it be CloudFlare related? I see they got a datacenter in Stockholm (where I am) already in 2012 and did have a few problems for some time, not sure today.

    Anything you want med to do?

    G.

    Thread Starter Mr. W

    (@gabriel-winnberg)

    Oh, just got your PM, Frank.

    Thread Starter Mr. W

    (@gabriel-winnberg)

    David, the url on your profile page doesn’t work.
    Was looking for you e-mail.

    Thread Starter Mr. W

    (@gabriel-winnberg)

    Absolutely. How do I dequeue the imagesLoaded and use a local file?

Viewing 15 replies - 1 through 15 (of 16 total)

The topic ‘Stops working with Autoptimize’ is closed to new replies.