async and defer Interview Questions (Ola)
Ola and other companies ask about async and defer. Here are the questions.
async and defer Interview Questions (Ola)
Q1: What is the difference between async and defer?
async: parallel download, execute when ready (unordered). defer: parallel download, execute after parse (ordered).
Q2: When would you use async?
For independent scripts: analytics, ads. Scripts that do not depend on other scripts or the DOM.
Q3: When would you use defer?
For most scripts: app logic, dependencies. Scripts that need the DOM and depend on other scripts.
Q4: What happens without async or defer?
The script blocks HTML parsing and rendering. The browser downloads and executes the script before continuing.
Q5: Do async scripts execute in order?
No. They execute in download order, not declaration order. If script B downloads before A, B runs first.
Q6: Do defer scripts execute in order?
Yes. They execute in the order they appear in the HTML, after parsing completes.
The Takeaway
Ola questions: difference (async=unordered, defer=ordered), when to use async (independent scripts), when to use defer (most scripts), what happens without them (blocking), and order guarantees (async=no, defer=yes).
async downloads in parallel and executes as soon as ready (unordered, briefly blocks parsing). defer downloads in parallel and executes after HTML parsing (ordered, non-blocking).
No. async scripts execute in whatever order they finish downloading. If a later script downloads first, it executes first. Use defer if order matters.
Yes. defer scripts execute in the order they appear in the HTML, after all HTML parsing is complete. This makes defer safe for scripts with dependencies.
The script blocks HTML parsing and rendering. The browser stops parsing, downloads the script, executes it, then resumes parsing. This makes the page feel slow.
defer is better for most cases. It does not block parsing or rendering and guarantees execution order. async is only better for independent scripts (analytics, ads) where order does not matter.
Ready to master React completely?
Want to upskill yourself, crack your next interview, and get your dream job? Join our comprehensive course to dive deeper with high-quality video tutorials, solve interview questions, and a premium community.
Master React
Want to upskill yourself, crack your next interview, and get your dream job? Join our comprehensive course.

