window.onload vs. body.onload vs. document.onready

Javascript

Javascript Problem Overview


What is the difference between window.onload, document.onready and body.onload ?

Javascript Solutions


Solution 1 - Javascript

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionalterView Question on Stackoverflow
Solution 1 - JavascriptalexView Answer on Stackoverflow