I'm new to javaScript. Whats the difference between window.onload and document.ready. I have used both and window.onload seems to fire a bit later than document.ready. Whats the reason?
Asked
Active
Viewed 8,016 times
1 Answers
3
$(document).ready: executes when HTML-Document is loaded and DOM is ready
$(window).load: executes when complete page is fully loaded, including all frames, objects and images

Akash Sinha
- 31
- 4
-
Thanks for the help. Which one should I generally use? – Bicku Bala Feb 07 '17 at 18:54
-
If your code is affected by external files like scripts and images, then use window.load else document.ready is fine. – Akash Sinha Feb 07 '17 at 18:57