Difference Between
load and DOMContentLoaded event
Document: DOMContentLoaded event
The DOMContentLoaded event is fired when the initial HTML document has been completely loaded and parsed, and all deferred scripts (<script defer src=""> and <script type="module">) have downloaded and executed, without waiting for stylesheest, images, and subframes to finish loading.
In many cases, using DOMContentLoaded is sufficient, without needed the window load event - which detect a fully-loaded page.
Window: load event
window's load event is only fired after the DOM and all dependent resources and assets have loaded.
References
Last Update: 11:54 - 18 April 2024