JavaScript · Junior · Question 46 of 75
How does DOMContentLoaded differ from load?
- ✓Correct answer:
DOMContentLoaded- the DOM is built;load- images and styles are loaded too - 2
loadfires earlier: as soon as the DOM is built, without images and styles - 3They're the same event under different names in different browsers
Explanation
DOMContentLoaded is enough for working with the DOM (defer scripts run right before it). load waits for all resources, including images and iframes - you need it, for example, to measure image sizes.