Difference between window.onload and $(document).redy
Pranay Rana
The ready event occurs after the HTML document has been loaded, while the onload event occurs later, when all content (e.g. images) also has been loaded.The onload event is a standard event in the DOM, while the ready event is specific to jQuery. The purpose of the ready event is that it should occur as early as possible after the document has loaded, so that code that adds funcionality to the elements in the page doesn't have to wait for all content to load.
window.onloadCode in this method get executed when DOM tree is ready.But fact is code in this method executed when DOM tree is ready and All the external resource are load like Images, Flash vidoe or quicktime video.Loading of the external resources deplay execution of the actual script when page get displayed.
$(document).redyCode in this method get executed once DOM tree loading is done.That means its not wait for the external resource get loaded. And run the javascript code which is in function.
So if you use Windows.onload than end user have to wait to see expected behaviour till DOM tree and external resouce get loaded by the browser. Where as in case of $(document).redy script get exeucuted once Dom tree loaded by browser.
window.onload() (