Difference between window.onload and $(document).ready()

Do you think $(document).ready() and window.onload are the same thing? Do you use one for the other? Do you use them interchangeably? If you do so, you are wrong. $(document).ready() and window.onload are not the same thing.

What did you think? They both get triggered when the page is loaded? They get triggered when the DOM is loaded?

The fact is they get triggered at different points in the page lifecycle.

$(document).ready() -> gets triggered when the DOM is loaded

window.onload -> gets triggered when the page is loaded with all the content like images, iframes etc.

Yes, they may sometimes get triggered almost at the same time if your page is only composed of DOM elements, but most of the time they will get triggered at different times, window.onload being triggered later.

Hope this helps.
Good Luck,

Serdar Osman Onur
I love coding web stuff, learning/applying new technologies and techniques to create things on the internet since 2004. AboutMe G+ twitter
Serdar Osman Onur


hard work, determination, dedication, patience, consistency, faith
https://t.co/8AqnoH4Hpb fallar, burclar gibi sacmaliklar icin hep soyledigim seyin bir adi varmis - 2 weeks ago
Serdar Osman Onur
Serdar Osman Onur

Latest posts by Serdar Osman Onur (see all)