Salesqueen Software Solution

Download Free Estimation Now Click Here
Notifications
Clear all

What is the difference between and ?

3 Posts
3 Users
0 Reactions
122 Views
Posts: 461
Topic starter
(@dinesha-g)
Reputable Member
Joined: 2 years ago

<window.onload> vs <onDocumentReady>

2 Replies
Posts: 52
(@chitravarsha15)
Trusted Member
Joined: 2 years ago

When the website loads in the browser, both functions are employed to carry out duties, but there are a few slight changes in how and when they are carried out.

When the browser has loaded the DOM tree and all other resources, including images, objects, etc., "window.onload" will run code.

Without waiting for other resources to load, onDocumentReady starts working as soon as the DOM tree is constructed. This enables faster onDocumentReady code execution against the DOM.

Another distinction is that, when utilising something like jQuery's document, window.onload is not cross-browser compatible.

All browsers will function correctly using ready().

 

 

Reply
Posts: 173
(@princy)
Estimable Member
Joined: 2 years ago

When the page has loaded in the browser, both the "window.onload" and "onDocumentReady" functions execute tasks; however, the two functions' methods of execution vary slightly.

  • onload: When a web page has finished loading, this event is launched. To put it another way, it waits for the DOM and all of the related resources to load before running any code. All HTML tags, including anchor, h1, p, and others, are contained in the DOM.
  • On the other hand, the "onDocumentReady" method runs the programme after the DOM has been loaded. Usually, it does not wait for images, videos, or other types of content, only for HTML tags, anchor tags, etc
Reply
Share: