• Resolved tonz003

    (@tonz003)


    Dear All!

    I have just updated autoptimize from 1.9.4 to 2.0.2…
    I hade VERY good PageSpeed Insights Score (98, 90) before but now my website has fallen apart…
    I had to disable “Optimize JavaScript Code?” and also I had to disable the following code in my functions.php to have the CSS work properly:

    add_filter( 'script_loader_tag', function ( $tag, $handle ) {
        if( is_admin() ) {
            return $tag;
        }
        return str_replace( ' src', ' defer src', $tag );
    }, 10, 2 );

    I need the new autoptimize because of the AMP.
    My website is: https://www.napelemek-napkollektorok.hu/
    Any help highly appreciated!

    Thank you in advance!

    https://wordpress.org/plugins/autoptimize/

Viewing 15 replies - 1 through 15 (of 23 total)
  • Plugin Author Frank Goossens

    (@futtta)

    afraid you’re going to have to be more specific tonz003;
    * why did you have to disable JS opt.? what breaks? what did you try to fix that?
    * the CCS-loading code (when doing inline&defer) is not enqueued via wordpress, so your code in functions.php should not intervene. what happens when that filter is active?

    frank

    Thread Starter tonz003

    (@tonz003)

    Dear Frank!

    First of all thank you for the very fast reply!

    I am not that pro coder, I am just a persistent advanced user, so sorry if I am not enough specific…

    I have enabled JS optimalization on the website. I do not know what is the problem, I just know that in the 1.9.4 version it was working like a charm! Now after the update it is not that good!

    I hope you can check it on my website and you can figure out what could cause the problem!

    Thank you for helping!

    Tony

    Plugin Author Frank Goossens

    (@futtta)

    ok, can you try excluding js/mappress.min.js from js optimization?

    frank

    Thread Starter tonz003

    (@tonz003)

    Actually I have disabled:
    Check this option for Autoptimize to also aggregate JS in the HTML. If this option is not enabled, you might have to “force JavaScript in head”.

    Now the video loads and the menu’s js also…

    But the Google Maps at the bottom of the page does not!

    I have added to the field: “,mappress.min.js”

    Thank you Frank for helping!

    Plugin Author Frank Goossens

    (@futtta)

    to remain as close as possible to AO 1.9.4, you should enable the aggregation of inline JS really … additionally you could use this filter to disable one of the new things in 2.0.x (see “My Autoptimized CSS/ JS is broken after upgrading from 1.9.4 to 2.0!” in FAQ);

    add_fitler('autoptimize_filter_js_inject_min_late','__return_false');

    add that in your (child) theme’s functions.php.

    if you; aggregate inline JS, not force JS in head and not exclude mappress.min.js, chances are all will work as before.

    frank

    Thread Starter tonz003

    (@tonz003)

    If I exclude mappress.js from optimization than I get bad score also for that!

    Also the post slider does not work properly…

    Before the upgrade it was very fast and worked perfectly… I got a couple of minus points because of only I had included font and google maps…
    Eve though the /amp/ was full with errors… Now, after the upgrade the /amp/ works perfectly without any error!

    I am trying to tell you the circumstance during the upgrade!

    Plugin Author Frank Goossens

    (@futtta)

    try the stuff I posted at the same time as you did πŸ™‚

    Thread Starter tonz003

    (@tonz003)

    I have configured as you said…

    Enabled Aggregation of inline JS
    Added to the function.php
    Added also the mappress.min.js

    If i turn on aggregation of inline js the website’s js not working.

    Thread Starter tonz003

    (@tonz003)

    Now it is configured as at 1.9.4 but with the filter in the functions.php and with excluded mappress.min.js

    Thread Starter tonz003

    (@tonz003)

    I have added to the function.php also the css filter… but I think the js is the problem! I could give you access if you would like to check out what could cause the problem!

    Plugin Author Frank Goossens

    (@futtta)

    you shouldn’t have to exclude mappress.min.js any more, can you remove it from the exclusion list?

    and when that is done empty AO’s cache to be sure we’re on a clean slate.

    Plugin Author Frank Goossens

    (@futtta)

    the css-filter is not needed, this indeed is a JS-issue.

    * don’t exclude mappress.min.js
    * clear cache
    * optionally try with the try-catch option on

    frank

    Thread Starter tonz003

    (@tonz003)

    Now mappress.min.js excluded…
    It does not work with try-catch option on!
    I always clear cache in the AO and in the W3TC and also in my browser.

    Plugin Author Frank Goossens

    (@futtta)

    Only thing remaining would be to compare the autoptimized JS created by 2.0.2 with the one created by 1.9.4. I’ll be happy to do so if you can provide me with the two files, that way we maybe can identify what is happening (because I’m stumped now, honestly).

    So:

    1. enable JS optimization in 2.0.2
    2. open the HTML of your homepage, look for cache/autoptimize/js/autoptimize and click through to see the optimized JS. you can copy/paste it on pastbin.com so I can see it
    3. download AO 1.9.4 here and overwrite plugins/autoptimize with it
    4. enable JS optimization if not active already (now in 1.9.4)
    5. open the HTML of your homepage, look for cache/autoptimize/js/autoptimize and click through to see the optimized JS. you can copy/paste it on pastbin.com so I can see it

    curious as to where this will lead us πŸ™‚

    frank

    Thread Starter tonz003

    (@tonz003)

    Dear Frank!

    I have done what you said, the only thing I had to split the JS files because free account wont’t let me paste so long code in pastebin…

    The code links:

    AO 1.9.4:
    HTML: http://pastebin.com/bdK2LgYF
    JS PART1: http://pastebin.com/A1MXWSEe
    JS PART2: http://pastebin.com/Taz3v2VT

    AO 2.0.4:
    HTML: http://pastebin.com/EWyjGaCG
    JS PART1: http://pastebin.com/CgZb0vvH
    JS PART2: http://pastebin.com/TpfFsuXy

    I hope we could find a solution!!!

    Thank you very much, taking the time looking into my problem!

    Best regards,
    Tony

Viewing 15 replies - 1 through 15 (of 23 total)
  • The topic ‘Autoptimize 2.0.2 error with async defer js’ is closed to new replies.