Caffeinated Coder
Book an appointment
Lesson 13 · How browsers use HTML

Loading scripts: defer and async

A browser reads HTML from top to bottom on one main thread, building the DOM as it goes. A plain <script src> tag stops that reading until the JavaScript file has downloaded and run. Follow one five-line page and one tiny app.js through three page loads: plain, defer and async. Watch the timeline, the DOM tree and the console to see when the script runs, what it can find, and when DOMContentLoaded fires.

12 min11 steps5 questionsAdvanced
Fig 13 · Interactive
Loading figure…
or ← →

Quiz Unlocks after the last step.