ForgeFrontend — Prepare, Practice, Crack
Secure checkout
Lifetime access
Instant Drive delivery
Free updates forever

Prepare · Practice · Crack

What's the difference between defer and async on a script tag?

Quick answer

Both download in parallel without blocking parsing. async runs as soon as it's ready (order not guaranteed); defer runs after parsing, in order.

In detail

A plain `<script>` blocks HTML parsing. `async` downloads in parallel and executes immediately when ready — good for independent scripts like analytics, but execution order isn't guaranteed. `defer` downloads in parallel but executes after the document is parsed, in document order — best for app scripts that touch the DOM.

<script src="analytics.js" async></script>
<script src="app.js" defer></script>

Why interviewers ask this: Performance-oriented question for page-load knowledge.

This is 1 of 118+ questions in the JavaScript Interview Kit

Get every question with detailed answers, follow-ups and real code — plus coding challenges and a last-minute revision sheet. One-time payment, instant access.

⚡ Get the JavaScript Interview Kit → ₹299

Full kit

JavaScript Interview Kit · ₹299

Get it →