Trending News
Home / Web Development / HTML / Difference between document.ready and window.onload or pageLoad

Difference between document.ready and window.onload or pageLoad

Hi all,
Today we are discuss one important topic related to document.ready and window.onload or pageLoad.


If the DOM is ready, jQuery’s document.ready() method gets called

  • The $(document).ready() function executes when HTML document is loaded and DOM is ready.
  • It is jQuery specific event
  • It is cross browser compactibility

  • It’sthe best for onetime initialization.
  • $(document).ready() is not called each and every partial postback of update panel
  • $(document).ready() is called only one time during first time of page loading.
  • code written in $(document).ready() method will not be initialized each and every partial postback.
  • Unable to re-attach the functionality to elements/controls of the page affected by partial postbacks.
  • The ready() method specifies what happens when a ready event occurs




The ready() method can only be used on the current document, so no selector is required:



jQuery(document).ready(function(){ });


$(document).on(‘ready’, function(){ })


This is a paragraph.



When images and all associated resources of the page have been fully loaded, the pageLoad() gets called.

  • The $(window).load() function executes when complete page is fully loaded, including all frames, objects and images.
  • Suppose your web page has large image size then until all the images are not fully loaded on the page, here the pageLoad() method will not called
  • This is not browser compactibility. Only call on web pages.



Simple Code


In this article I try to share the differnce between document.ready() and window.onloadorpageLoad(). I hope this article helps you in your coding language and also understand the use of both these methods.

If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.

Loading Facebook Comments ...
Social Media Auto Publish Powered By :