Is there a difference, performance or efficiency wise, between placing javascript calls such as blur, onclick etc. in $(document).ready(function(){ as opposed to placing them in HTML?
Thanks!
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.
I think by “in the DOM” you mean this:
right? If so, then it’s not so much about performance as it is about maintainability and power. Using jQuery (since you mentioned the “ready” handler in jQuery terms) to bind your events lets the framework take care of managing multiple handlers, and dealing with browser differences.
In fact sometimes it’s even better to not bind directly to elements at all. Instead, you can use the jQuery “live” or “delegate” mechanisms to help cut down on actual handler bindings and provide for a more dynamic DOM.