Atul Jain
What is the difference between window.onload and onDocumentReady in JavaScript?
By Atul Jain in JavaScript on Aug 13 2012
  • Pranay Rana
    Jan, 2014 17

    window.onload- Code 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).redy- Code 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.

    • 1


Most Popular Job Functions


MOST LIKED QUESTIONS