Web Browser - Load Event

About

The load event is fired by the browser.

Example

Image

With a onLoad content event handler, you can be updated when the image has finish loading

<img src="/_media/resume/nico.jpg" onLoad="console.log('The image has loaded')" />

Page

Doc

With a onLoad IDL event handler, you also check if the window (ie page) has finished loading.

window.onload = () => { console.log("The page has been loaded") };

Other

document - DOMContentLoaded

This is not a event called on load event but as it's really similar…

DOMContentLoaded is called when the DOM is ready which can be prior to images and other external content is loaded.

document.addEventListener('DOMContentLoaded', (event) => {
    console.log('DOM fully loaded and parsed');
});

Doc


Powered by ComboStrap