defer, async and module

How scripts load matters for speed.

HTML · defer, async and moduleIntermediate
<!-- Runs after the HTML is parsed, in order. Best default. -->
<script src="app.js" defer></script>

<!-- Runs as soon as it is downloaded. For independent scripts (analytics). -->
<script src="analytics.js" async></script>

<!-- Modern module, deferred automatically. -->
<script type="module" src="main.js"></script>
<script nomodule src="legacy.js"></script>
scriptdeferasyncmodule