window.onload() - It is a Java script pre-defined function.
document.ready() It is a jQuery event which are called when page is loaded.
The basic difference between these :-
document.ready() is called after the DOM is loaded without waiting for all the contents to get loaded.But other side window.onload() function waits until the all contents of page is loaded.
Example:-
Suppose there is large image on a page, until that image is not loaded completely window.onload() will wait till then in such case.
But the document.ready() will not wait until the image is loaded.
This is the reason for window.onload() function the execution will be slow in compare to using document.ready over there in place of window.load.
0 Comment(s)