I have been taking a look on some sites and they all talk about using tag selectors instead of classes to improve the performance.
For example, this:
$("input.myclass");
Instead of this:
$(".myclass");
For example:
- http://www.artzstudio.com/2009/04/jquery-performance-rules/#use-tags-before-classes
- Good ways to improve jQuery selector performance?
- http://www.thewebsqueeze.com/web-design-tutorials/improve-your-jquery-selectors-5-quick-tips.html
They all claimed that JavaScript only had getElementById
and getElementsbyTagName
and not a way to select classes directly.
Has this changed in the last 3 years? Are they now able to select by class? I was testing it with jsperf and it seems the class selector is faster by far: http://jsperf.com/class-vs-input
I also took a look at other's people testings and show the same results: http://jsperf.com/selectors-perf/3
Has this changed in these last year? Should we now select by class rather than by tags? Where can I take a look at the browsers' versions implementing natively the class selector?
Thanks.