Skip to main content
InterviewHubPRO
Section Overview
Q39

Question 39 of 50

Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

78%
HTML5 & Web APIs (50 Qs)•Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

Script Loading Strategies: `async` vs `defer` vs `type="module"`.

senior LevelAsync & PromisesSystem Design

In Simple Words:

  • <script src="..."> (Default): Blocks HTML parsing while downloading and executing immediately.
  • <script async src="...">: Downloads in background without blocking HTML parsing. Executes immediately when downloaded, interrupting parsing and executing out of order. Best for independent analytics scripts.
  • <script defer src="...">: Downloads in background without blocking. Executes only after HTML parsing completes, preserving original DOM document order before DOMContentLoaded. Best for application code.
  • <script type="module" src="...">: Behaves like defer by default, supports ES imports, and always executes in strict mode.