1

What is the difference between

 $(window).load(function () {});

And

 $(window).ready(function () {});

What is the difference between window load and window ready?

Pearl
  • 8,373
  • 8
  • 40
  • 59

2 Answers2

0

window.ready occurs when all of the DOM has been loaded but images may not have been loaded

window load occurs after all images have finished loading

ready event happens first so most code can be placed her

window.onload vs $(document).ready()

Community
  • 1
  • 1
actual_kangaroo
  • 5,971
  • 2
  • 31
  • 45
0
  • document.ready is a jQuery event, it runs when the DOM is ready

  • window.onload fires later when images and such are loaded

Example Script

$(document).ready(function() {
 // executes when HTML-Document is loaded and DOM is ready
 alert("document is ready");
});


$(window).load(function() {
 // executes when complete page is fully loaded, including all frames, objects and images
 alert("window is loaded");
});

Refer

Difference between window load and window ready

window.onload vs. body.onload vs. document.onready

Community
  • 1
  • 1
Sridhar R
  • 20,190
  • 6
  • 38
  • 35