$(document).ready(function(){})
It will wait for the document to load (the DOM tree is loading), and not until the entire window is loaded. for example, it will not wait for the full download of images, css or javascript. When the DOM is loaded by all HTML components and event handlers, the document is ready for processing, and then $ (document) .ready () will complete
$(window).load(function(){});
This is the wait for the entire window to load. When the whole page loads, only $ (window) .load () ends. Therefore, it is obvious that $ (document) .ready (function () {}) ends before $ (window) .load (), because it takes more time to fill in components (for example, images, css), and then the tree just loads DOM
So $(function(){});
cannot be used as a replacement for $(window).load(function(){});
source share