If there are 2 or 3 or 20 statements using jQuery’s
$(function() { ... })
to add functions to be executed when the DOM is ready, will all those functions run in parallel or run in sequence?
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.
document.readybehaves like a normal event in this respect, they happen in a sequence and in the order they were bound. You can see the relevant jQuery core source here:This is what happens when you do
$(function):And this happens later, when the “ready” event fires:
If the document’s already ready, the function executes immediately, that’s the
ifpart in the first code block above.