Thursday 6 June 2013

Is window.onload is different from document.ready()?

- The window.onload() is Java script function and document.ready() is jQuery event which are called when page is loaded.

- The difference is that document.ready() is called after the DOM is loaded without waiting for all the contents to get loaded. While window.onload() function waits until the contents of page is loaded.

- Suppose there is very large image on a page, at that time window.onload() will wait until that image is loaded totally.

- So while using the window.onlaod() function the execution will be slow, but the document.ready() will not wait until the image is loaded.

No comments:

Post a Comment