HTML & CSS · Senior · Question 49 of 75

How does defer differ from async on <script>?

Explanation

A regular script stops the parser. defer downloads in parallel and executes in order before DOMContentLoaded - good for dependent application scripts. async executes as soon as it's downloaded - for independent scripts like analytics. Modules (type="module") behave like defer by default. Neither attribute affects inline scripts.

Further reading

Problem with a question

HTML & CSS · Senior · question 49

Test yourself

Take the HTML & CSS · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz