Paul
Paul

Reputation: 1014

What's the first event fired when a web page is loaded to the browser

As asked in the title, what's the first event fired when a web page is loaded to the browser? I believe there are events before window.onload. What are they, and which one is the first fired?

Upvotes: 8

Views: 5169

Answers (3)

Tom Winter
Tom Winter

Reputation: 1913

This looks to have some of what you're looking for:

[Updated link - link-rot - this is why you copy and paste essential information directly into an answer]

https://web.archive.org/web/20090131201912/http://dean.edwards.name:80/weblog/2005/02/order-of-events/

Upvotes: 0

Mike Sav
Mike Sav

Reputation: 15291

Don't know if this helps but firebug/IE Dev Tool is really good for watching JS events execute as the page loads. I use that to caputre events and see the order of how they're happening.

Upvotes: 0

meder omuraliev
meder omuraliev

Reputation: 186562

If you're looking to invoke an event handler before onload, DOMContentLoaded is one event that usually fires before.

document.addEventListener('DOMContentLoaded', functionRef, false);

Upvotes: 5

Related Questions