0

Difference between <script>, <script async>, and <script defer>?

author
pranav m
easy
1
27


Answer
  • <script> (default)
    • Blocks HTML parsing until script is loaded and executed.
    • Slows rendering.
  • <script async>
    • Loads script asynchronously (parallel with HTML parsing).
    • Executes as soon as it’s ready (may interrupt parsing).
    • Best for independent scripts (ads, analytics).
  • <script defer>
    • Loads script asynchronously (like async).
    • Executes after HTML is fully parsed, in order they appear.
    • Best for scripts that depend on DOM.

Summary

Attribute

Load

Execute

none

Blocking

Immediately (blocks parsing)

async

Parallel

As soon as loaded (non-sequential)

defer

Parallel

After parsing (sequential)

Click to Reveal Answer

Tap anywhere to see the solution

Revealed

Comments0
    Difference between <script>, <script async>, and <script defer>? - script | EBAT