1. DOMContentLoaded: the browser fully loaded HTML, and the DOM tree is built, but external resources like pictures <img> and stylesheets may be not yet loaded.
  2. load: not only HTML is loaded, but also all the external resources: images, styles etc.
  3. beforeunload/unload: the user is leaving the page.

DOMContentLoaded

document.addEventListener("DOMContentLoaded", ready);
// not "document.onDOMContentLoaded = ..."

DOMContentLoaded and scripts

<script>
document.addEventListener("DOMContentLoaded", () => {
	alert("DOM ready!");
});
</script>
<script src="[<https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.3.0/lodash.js>](<https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.3.0/lodash.js>)"></script>
<script>
alert("Library loaded, inline script executed");
</script>

DOMContentLoaded and styles