Wondering when does a load event occur in a browser? Is it when it receives the header information?
As a web page loads, it emits two events. These are: load , firing when all initial resources are ready: including scripts, images and CSS. DOMContentLoaded , firing when the HTML payload arrives and all non-async scripts have run.
The onload attribute fires when an object has been loaded. onload is most often used within the <body> element to execute a script once a web page has completely loaded all content (including images, script files, CSS files, etc.).
The DOMContentLoaded event fires when the initial HTML document has been completely loaded and parsed, without waiting for stylesheets, images, and subframes to finish loading. A different event, load , should be used only to detect a fully-loaded page.
The load event is fired when the document has been fully processed. When images are loaded eagerly (which is the default), every image in the document must be fetched before the load event can fire.
onload is triggered after the entire document, images and all, are loaded.
Some browsers, like Firefox, also have on-content-load events that are triggered after the HTML file is delivered, but before external files like images are loaded.
onload occurs when all the data has been downloaded, including all css, javascript and image files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With