Is there a definite sequence for these events to trigger?, So that we can write our initialization accordingly.
Asked
Active
Viewed 1,429 times
2 Answers
1
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.
So document.ready
will trigger first and window.load
will trigger later

Dhara Parmar
- 8,021
- 1
- 16
- 27
0
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.
Please read here window.onload vs $(document).ready()

Community
- 1
- 1

Ashisha Nautiyal
- 1,389
- 2
- 19
- 39