Async Loading
Downloading a resource in parallel without letting it hold up the rest of the page.
Analogy Mental model
Several cooks working different dishes at once, rather than waiting for the first to finish before starting the second.
In practice What you actually do
async downloads and runs as soon as it arrives, in whatever order, so it suits independent tags such as analytics. defer downloads while the parser works and runs in document order afterwards, which is what you want when one script depends on another.
Where people get burned Pitfalls
The two attributes cannot be combined, and neither applies to an inline script. Choosing defer for an independent tag costs a few hundred milliseconds of measurement, which is usually worth knowing about.
This entry was written in English from the Chinese original, not machine-translated. Read the Chinese version →