jQuery - $(document).ready vs $(window).load()

0 votes
330 views
added Jun 27, 2019 in jQuery by LC Marshal Captain (25,770 points)
edited Jul 12, 2019 by LC Marshal
//$document.ready function event executes earlier than window.onload. DOM present before images 
$( document ).ready(function() {
  console.log( "I'm faster" );
});

//Windows load event trigger only when all contents fully loaded, including DOM
// Useful for DFP unit, wait till its present then fired.
$(window).load(function() {
  console.log( "I'm patient" );
});

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...