Disclaimer: Do not try this at home
Why, if I am using jQuery, does $($) freeze the page?
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.
$($)is a shortcut for$(document).ready($). So, it will run the function (when the DOM is ready or directly when this is already the case).The function passed to
.readyis passed the jQuery function for convenience (especially useful when you’re innoConflictmode). So,$($)will call$with$as argument – and everything will happen again, which is endless recursion.Another explanation:
$($).$) to an internalreadylist.readylist”.readylist is$, so it calls$.$function as the argument to those functions.$with$as argument.$function sees a function as its argument, but because the DOM is ready, it calls the function directly (there is nothing to wait for).$function is called with$as the argument.