Quiz

Why would you use something like the `load` event?

Does this event have disadvantages? Do you know any alternatives, and why would you use those?
Topics
Web APIsJavaScript

The load event fires at the end of the document loading process. At this point, all of the objects in the document are in the DOM, and all images, scripts, links, and sub-frames have finished loading.

The DOM event DOMContentLoaded fires after the DOM for the page has been constructed, but does not wait for other resources to finish loading. This is preferred in cases where you do not need the full page to be loaded before initializing.

Exercises

Check your understanding
Beta
Check your understanding Exercise
Check your understanding Exercise

A script only needs the parsed DOM to attach behavior; it does not depend on images or subframes finishing. Which event is the better readiness boundary?