📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

📚 Interview question

What is the difference between DOMContentLoaded and the load event, and which should page scripts wait for?

Beginner Theory Beginner

🎯 Key points

  • DOMContentLoaded = HTML parsed + deferred/module scripts executed
  • load = all subresources (images, iframes, styles) finished
  • Module and defer scripts already run before DOMContentLoaded, so no listener is needed
  • Starting on DOMContentLoaded lets users interact while images are still downloading
  • load is only for code that needs final image dimensions or every resource
  • A slow third-party image or ad can delay load by seconds

⏱ 30-second answer

DOMContentLoaded fires when the HTML is fully parsed and deferred and module scripts have run, without waiting for images, iframes or late stylesheets. load fires only when every subresource, including images, has finished. Most app code only needs the DOM, so it should run at DOMContentLoaded (or simply as a defer/type="module" script): users can interact sooner, which helps perceived performance and INP. Waiting for load holds interactivity hostage to the slowest image. Use load only for code that genuinely needs final image sizes or every resource, such as measuring layout.

🔍 What the interviewer is checking

Checks they understand page lifecycle events

↩ Usually asked after

More in Web Basics

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me