Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

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

user-image
Question ajoutée par Utilisateur supprimé
Date de publication: 2015/10/10
Magdy Hassan
par 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
par 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
par 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
par 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

Avez-vous besoin d'aide pour créer un CV ayant les mots-clés recherchés par les employeurs?