Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

What are the difference between jquery $(windows).load() and $(document).ready()?

user-image
Question added by Deleted user
Date Posted: 2015/10/10
Magdy Hassan
by Magdy Hassan , Senior Web Developer , Massive Solutions

$(document).ready() executes when HTML-Document is loaded and DOM is ready

$(windows).load() executes when complete page is fully loaded, including all frames, objects and images

The ready event occurs after the HTML document has been loaded, while the onload event occurs later, 

when all content (e.g. images) also has been loaded.

The onload event is a standard event in the DOM, while the ready event is specific to jQuery. The purpose of the ready event is that it should occur as early as possible after the document has loaded, so that code that adds functionality to the elements in the page doesn't have to wait for all content to load.

Ibtisam Ul Haq
by Ibtisam Ul Haq , Full Stack Developer

$(windos).load() will wait to complete all http request including rending of images/videos etc where as $(docment).ready() will wait till the document/html page render on in other word when dom is ready.

Suresh kumar
by Suresh kumar , Sr Web Developer , Clerisy Solution Private limited

Yes, you are right rehan . $(document).ready() we use when you want to fire event on dom load and window loaf is used when all content get loaded.

Rehan Farooq
by Rehan Farooq , WEB DEVELOPER/DIGITAL MARKETING EXPERT , Upwork

The difference are:$(document).ready(function() { is jQuery event that is fired when DOM is loaded, so it’s fired when the document structure is ready.$(window).load() event is fired after whole content is loaded.

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.