Can you list the difference between onload() and $(document).ready(function(){..}) functions in the using jQuery?
Can you list the difference between onload() and $(document).ready(function(){..}) functions in the using jQuery?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
the
loadevent (a.k.a “onload”) on the window and/or body element will fire once all the content of the page has been loaded — this includes all images, scripts, etc… everything.In contrast, jquery’s
$(document).ready(...)function will use a browser-specific mechanism to ensure that your handler is called as soon as possible after the HTML/XML dom is loaded and accessible. This is the earliest point in the page load process where you can safely run script that intends to access elements in the page’s html dom. This point arrives earlier (often much earlier) than the finalloadevent, because of the additional time required to load secondary resources (like images, and such).