jQuery class vs attribute selectors (v11)

Revision 11 of this benchmark created by Jose Antonio Marquez Russo on


Description

Test performance of jQuery of using the class selector ".classname" vs the attribute selector "[class='classname']"

Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<div class="nothing nothing2 content nothing3">
  <div class="nothing1 sub-content nothing3" data-test=true>
    Lorem ipsum dolor sit amet.
  </div>
</div>

Test runner

Ready to run.

Testing in
TestOps/sec
class selector
var content = jQuery('.content .nothing1.sub-content');
ready
attribute selector
var content = jQuery('.content .nothing1[data-test=true]');
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.