JavaScriptIntermediate#browser#performance

What is the difference between defer and async on a script tag?

Both download the script without blocking parsing. async executes as soon as it is ready, in unpredictable order; defer waits until the HTML is parsed and preserves document order.

Example
<script src="analytics.js" async></script>
<script src="app.js" defer></script>

Related Questions

1
JavaScriptAdvanced#performance#memory

What causes memory leaks in JavaScript?

Open
2
JavaScriptBeginner#types

What is the difference between typeof and instanceof?

Open
3
JavaScriptIntermediate#fundamentals

What is strict mode?

Open