4 ms·
Footnote: if the scripts are not necessary for interaction, moving them to the footer and marking them deferred/async allows you to prevent the browser preloade
by lelandfe 4y ago
Footnote: if the scripts are not necessary for interaction, moving them to the footer and marking them deferred/async allows you to prevent the browser preloader[0] from being too eager with downloading them during downtime.
This is effectively a poor man's resource priority hints[1], allowing the developer the ability to prioritize downloads for the browser.
[0] https://andydavies.me/blog/2013/10/22/how-the-browser-pre-loader-makes-pages-load-faster/ https://andydavies.me/blog/2013/10/22/how-the-browser-pre-lo...
[1] https://wicg.github.io/priority-hints/ https://wicg.github.io/priority-hints/
- masswerk 4y agoYes, the end of the document + `async` is probably still the way to go for analytics scripts and similar things. (`defer` will still block the initial render.)
- lelandfe 4y agoOther way round. Neither blocks parsing/render during downloads, but async scripts execute immediately onLoad – blocking render. defer "defers" that until after document parsing is finished. https://developer.mozilla.org/en-US/docs/Learn/JavaScript/First_steps/What_is_JavaScript#async_and_defer https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Fi...