window.onload vs. body.onload vs. document.onready [duplicate]

window.onload will wait until all assets have finished downloading, such as images and scripts.

DOM ready waits until you can access the DOM via the API.

As a side note, in this day and age, you ought to be using window.addEventListener('load', function() { }, false) or attachEvent() for older IEs.

Leave a Comment