Scripts: async, defer thumbnail
Scripts: async, defer
javascript.info
The defer attribute tells the browser not to wait for the script. Instead, the browser will continue to process the HTML, build DOM. The script loads “in the background”, and then runs when the DOM is fully built. Scripts with defer never block the page. Scripts with defer always execute when the DO
2 Users
0 Comments
8 Highlights
0 Notes

Top Highlights

  • The defer attribute tells the browser not to wait for the script. Instead, the browser will continue to process the HTML, build DOM. The script loads “in the background”, and then runs when the DOM is fully built.
  • Scripts with defer never block the page. Scripts with defer always execute when the DOM is ready (but before DOMContentLoaded event).
  • Dynamic scripts behave as “async” by default.
  • Both async and defer have one common thing: downloading of such scripts doesn’t block page rendering
  • In practice, defer is used for scripts that need the whole DOM and/or their relative execution order is important.

Ready to highlight and find good content?

Glasp is a social web highlighter that people can highlight and organize quotes and thoughts from the web, and access other like-minded people’s learning.