Menu
Document Structure & Metadata

<script> Tag

Embed or load JavaScript. Master defer, async, and module.

1Loading JavaScript

Use defer for normal page scripts so they download in parallel but execute after HTML parses. Use async only for independent scripts (analytics).

Example Code
<!-- External, deferred -->
<script src="/app.js" defer></script>

<!-- ES module -->
<script type="module" src="/main.js"></script>

<!-- Inline -->
<script>
  console.log('Hello');
</script>

Finished reading?

Mark this topic as complete to track progress.