Is there any difference between body onload() and document.ready() function?

Technology CommunityCategory: jQueryIs there any difference between body onload() and document.ready() function?
VietMX Staff asked 3 years ago

document.ready() function is different from body onload() function for several reasons:

  1. We can have more than one document.ready() function in a page where we can have only one body onload function.
  2. document.ready() function is called as soon as DOM is loaded where body.onload() function is called when everything gets loaded on the page that includes DOM, images and all associated resources of the page.