javascript - Defer, Async and the PageSpeed Insights -


i try optimize page speed load using recommendations of pagespeed insights about, particularly, deferring javascripts, in order not block page content render.

so, appears html5 introduced preatty cool feature, async attribute, permits load scripts asynchronously in "chaotic" mode. there attribute, defer one, loads them asynchronously, in "ordered" mode (as understood that article).

so, concluded

  1. always use (for every <script src='my.js'>) defer attribute.
  2. in case if script not "load critical" (like jquery, or jquery-ui) async attribute can used.

is right conclusion ?

ps.

complimentary question:
fact of adding scripts at end of document, automatically "unblocks" rendering of document? understand, scripts blocks rendering, without difference of location in document (the <head> or before </body>)...

1. use (for every <script src='my.js'>) defer attribute.

you should defer scripts can deferred. in cases may need guarantee execution order, or rely on features must happen inline. example, scripts call document.write must not deferred.

2. in case if script not "load critical" (like jquery, or jquery-ui) async attribute can used.

"load critical" doesn't have specific meaning, it's poor choice of phrasing. async should used scripts can execute in order , aren't dependency of other scripts.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -