The general idea is that window.onload fires when the document's window is ready for presentation and document.onload fires when the DOM tree (built from the markup code within the document) is completed.
window.onload can take a while to fire, when multiple external resources have yet to be requested, parsed and loaded.
To observe the difference and how your browser of choice implements the aforementioned event handlers, simply insert the following code within your document's -
Here is the resulting behavior, observable for Chrome v20 (and probably most current browsers).
onloadfires twice when declared inside the
<body>, once when declared inside the
<head>(where the event then acts as
window.onloadevent handler within the confines of the HTML-
The code above is taken from this project's codebase (
For a list of event handlers of the window object, please refer to the MDN documentation.