Sobes.tech
Middle

What is the difference between <script>, <script async>, and <script defer> tags?

sobes.tech AI

Answer from AI

  • <script>: HTML parsing stops, the script is loaded and executed immediately, then HTML parsing resumes.
  • <script async>: The script is loaded in parallel with HTML parsing and executed as soon as it is loaded. HTML parsing is not blocked during loading but may be paused during script execution. The execution order of async scripts is not guaranteed.
  • <script defer>: The script is loaded in parallel with HTML parsing, but its execution is deferred until HTML parsing is complete. Scripts with defer are executed in the order they appear in the HTML. It does not block page rendering.
Attribute HTML parsing during loading HTML parsing during execution Execution order
None Stops Stops In order
async Continues May pause Not guaranteed
defer Continues Continues In order