I've seen lots of posts comparing the speeds of various selector queries and DOM traversal methods. Of course it matters in cases with hundreds or thousands of elements and O^n operations, but does speed really matter in the 99% of cases where Jquery does some DOM manipulation (or whizzy animation, or makes toast) in response to a user action?
Won't almost all JQuery actions be faster than a round-trip to the server?
It makes sense to design uber-optimized server-side code. And it makes sense to be responsible with memory allocation and clean up in javascript so the user's browser doesn't run like Flash circa v5. I don't see any sense in wasting time optimizing the speed of JQuery / Javascript unless something noticeably slows the page down during testing.
Could somebody please tell me if and why I should start caring about JQuery speed?
Edit
My tone is admittedly whiny but not meant to be argumentative. There are good resources on how to approach optimization when you need to here, a better way to ask my question would have been:
What is the impact of sub-optimal Javascript / Jquery?
If I don't notice it, should I worry about it?
Accepted
After reading the responses I think the best answer to this question depends on your project and team size. In situations where programmers don't have a full view of the page the user will see, such as teams where
- programmers are responsible for individual features on a page
- programmers develop and unit test independently
- there is a bespoke front-end API or other code which could impact actual response times
Then it makes sense to be more careful and 'prematurely optimize' as routine. This is feasible in cases where there are specialist, professional front-end designers who do nothing else.
On smaller projects, such as my current two-man team:
- the lack of specialization
- the need for high programmer output
- the concentrated responsibility for the entire front-end in one person
All push optimization down on the priority list. @Anurag's answer helped me get to the core of the question and make the best decision.