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.