Note that there are some explanatory texts on larger screens.

plurals
  1. POImprove selectors performance with jQuery
    primarykey
    data
    text
    <p>I have been taking a look on some sites and they all talk about using tag selectors instead of classes to improve the performance.</p> <p>For example, this:</p> <pre><code>$("input.myclass"); </code></pre> <p>Instead of this:</p> <pre><code>$(".myclass"); </code></pre> <p>For example:</p> <ul> <li><a href="http://www.artzstudio.com/2009/04/jquery-performance-rules/#use-tags-before-classes" rel="nofollow noreferrer">http://www.artzstudio.com/2009/04/jquery-performance-rules/#use-tags-before-classes</a></li> <li><a href="https://stackoverflow.com/questions/46214/good-ways-to-improve-jquery-selector-performance">Good ways to improve jQuery selector performance?</a></li> <li><a href="http://www.thewebsqueeze.com/web-design-tutorials/improve-your-jquery-selectors-5-quick-tips.html" rel="nofollow noreferrer">http://www.thewebsqueeze.com/web-design-tutorials/improve-your-jquery-selectors-5-quick-tips.html</a></li> </ul> <p>They all claimed that JavaScript only had <code>getElementById</code> and <code>getElementsbyTagName</code> and not a way to select classes directly.</p> <p>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: <a href="http://jsperf.com/class-vs-input" rel="nofollow noreferrer">http://jsperf.com/class-vs-input</a></p> <p>I also took a look at other's people testings and show the same results: <a href="http://jsperf.com/selectors-perf/3" rel="nofollow noreferrer">http://jsperf.com/selectors-perf/3</a></p> <p>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?</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload