Skip to content
techsnow

Head Elements

Script Tag

The <script> tag adds JavaScript to the page, either written inside it or loaded from a file.

<!-- external file (recommended) -->
<script src="app.js" defer></script>

<!-- inline -->
<script>
  console.log("Page loaded!");
</script>
AttributeBehaviour
(none)Stops the page loading until the script has downloaded and run.
deferDownloads in the background and runs after the HTML is ready, in order. Best for most scripts.
asyncDownloads in the background and runs as soon as it arrives, in any order. Good for analytics.
type="module"Loads modern JavaScript modules. Deferred automatically.