• Hi,

    I am trying to defer parsing of a JS script based on Google’s recommendation and the plugin is not doing anything. I have tried several settings, but the last ones are:

    Enable Async JavaScript? > Checked
    Also enable Async JavaScript for logged in users? > Checked
    Also enable Async JavaScript on cart/ checkout pages? > Checked
    Async JavaScript Method > Defer
    jQuery > Defer
    Scripts to Defer > https://www.carlosazuaje.com/wp-content/cache/minify/ad843.js

    I am still getting the same message on Google’s PageSpeed Insights and also on GTmetrix.

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

    (@optimizingmatters)

    That’s because AsyncJS adds defer (or async) to JS that was added to wordpress using wp_enqueue_script Carlos, but you have another plugin that is minifying that enqueued JS and AsyncJS does not “see” that. So if you want to use asyncJS to async your JS, you will have to disable JS minification (or use anohter minifier).

    hope this clarifies,
    frank

    Thread Starter Carlos Azuaje

    (@carlosazuaje)

    Hey Frank,

    Thanks for the fast response. What do you recommend then to minify all my JS but also defer the script? Obviously, I don’t want to only defer the script and not be able to minify the rest of my JS.

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    I might be am biased, but if I were you I would give Autoptimize a try πŸ˜‰

    Thread Starter Carlos Azuaje

    (@carlosazuaje)

    I actually gave it a try a while ago but had to deactivate it because it gave me problems.

    So in summary, AsyncJS won’t work if I have another plugin that is not Autoptimize minifying my JS, right?

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    depends on how the minifying plugin works actually, if it only replaces the script source but leaves the rest of the script tag (including the async or defer flag) intact, then you’re good to go. apperantly the one you’re using now (which one is that) works differently.

    regarding AO; don’t know when you tried and what the issue was, but AO now also has an option not to aggregate (which means it acts more or less how your current minifier works). and well, almost all problems can be fixed by some troubleshooting πŸ˜‰

    Thread Starter Carlos Azuaje

    (@carlosazuaje)

    Thank you.

    I am using W3 Total Cache, which minifies HTML, CSS and JS (same as Autoptimize). I understand that running the two plugins together causes problems, that’s why I only have W3 Total Cache activated.

    If I understand you correctly, are you saying that I can run Autoptimize together with W3 Total Cache and make AsyncJS work?

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    If I understand you correctly, are you saying that I can run Autoptimize together with W3 Total Cache and make AsyncJS work?

    you can, if you disable all minification in W3TC to avoid conclicts.

    Thread Starter Carlos Azuaje

    (@carlosazuaje)

    Is that the only way to make AsyncJS work?

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    well, you could try finding another minification plugin, but I don’t know how the others work tbh, so can’t say for sure. it is possible fast velocity minify (which is great) can help and maybe that even has asyncing in it.

    Thread Starter Carlos Azuaje

    (@carlosazuaje)

    Thank you for your support.

    Have a great coming year! πŸ™‚

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    you’re welcome Carlos, happy new year! πŸ™‚

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘Can’t Defer JS’ is closed to new replies.