• Resolved David Elstob

    (@davwaiguy)


    Raul,

    I realise you prefer not to use Rocket Loader, which runs the JS asynchronously. However, when I try using defer JS using FVM it doesn’t work for me. (You do say it might not work to be fair.)

    So my point is, how about offering an Async option for JavaScript as well?

    That way I can forget Rocket Loader completely and will save one HTTP call in the process plus my JS won’t be render blocking either.

    Cheers, David

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Raul P.

    (@alignak)

    I recommend you to read what async really means, and the impact it may have on your site functionality.

    https://idiallo.com/javascript/async-jquery

    Async means that your browser and network will decide when to download the file, which can be faster that the time it needs to render the html page, or slower.
    If it’s slower (ex: slow 3G mobile), any function that depends on jquery will stop working, and since this never behaves the same… you cannot test it, but your users will have trouble.

    In short, you can only async scripts which work independently, such as ads, or libraries that do not depend on anything else AND no inlined code also depends on it.

    jQuery is on most of the cases, render blocking because plugins and themes inject inline javascript on the page that rely on jquery being loaded first.
    With async, there is no guarantee that it will ever load first, even if for you, it always works.

    Therefore, the only way to preserve the order of scripts is with defer, not async.
    You can still use async for other stuff which can load completely independent, such as ads or other external scripts.

    Thread Starter David Elstob

    (@davwaiguy)

    Thanks for the response, Raul.

    The reason that I mentioned Async Loading is because that is how Rocket Loader works and after testing with and without Rocket Loader running, my site starts rendering faster with Rocket Loader turned on, but Rocket Loader introduces one extra call as you know.

    Also Defer doesn’t always work; we can’t rely on it 100%.

    So my thinking is if you offered an Async option it would mean it could be used instead of Rocket Loader and would give people an other option.

    Just a thought!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Async Loading JavaScript’ is closed to new replies.