Difference between $(document).ready and $(window).load

You are here because you are not satisfied with the answers from other forums as they described it in detail and offcourse we don’t have time to read it at all.

You are still confused what they actually do and WHEN, right?

$(document).ready

It means your document or page is capable of executing your javscript/jQuery functions.

For Example
$(document).ready(function(){
alert("It will load as soon as document is capable of executing it");
});

$(window).load

It means your document is ready to execute javascripts but they are execute after whole page is loaded. For Example
$(window).load(function(){
alert("It will load after page is loaded");
});

Advertisements