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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s