DOM lookups in classes

JavaScript performance comparison

Test case created by Josh

Info

lkasdlf

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>


<ul id="products-list">
<li class="product" data-catalog-id="1025153">list item</li>
<li class="product" data-catalog-id="1025153">list item</li>
<li class="product" data-catalog-id="1025153">list item</li>
<li class="product" data-catalog-id="1025153">list item</li>
<li class="product" data-catalog-id="1025153">list item</li>
<li class="product" data-catalog-id="1025153">list item</li>
<li class="product" data-catalog-id="1025153">list item</li>
<li class="product" data-catalog-id="1025153">list item</li>
<li class="product" data-catalog-id="1025153">list item</li>
<li class="product" data-catalog-id="1025153">list item</li>
<li class="product" data-catalog-id="1025153">list item</li>
<li class="product" data-catalog-id="1025153">list item</li>
<li class="product" data-catalog-id="1025153">list item</li>
<li class="product" data-catalog-id="1025153">list item</li>
<li class="product" data-catalog-id="1025153">list item</li>
<li class="product" data-catalog-id="1025153">list item</li>
<li class="product" data-catalog-id="1025153">list item</li>
<li class="product" data-catalog-id="1025153">list item</li>
<li class="product" data-catalog-id="1025153">list item</li>
<li class="product" data-catalog-id="1025153">list item</li>
<li class="product" data-catalog-id="1025153">list item</li>
<li class="product" data-catalog-id="1025153">list item</li>
<li class="product" data-catalog-id="1025153">list item</li>
<li class="product" data-catalog-id="1025153">list item</li>
<li class="product" data-catalog-id="1025153">list item</li>
</ul>

Preparation code output

  • list item
  • list item
  • list item
  • list item
  • list item
  • list item
  • list item
  • list item
  • list item
  • list item
  • list item
  • list item
  • list item
  • list item
  • list item
  • list item
  • list item
  • list item
  • list item
  • list item
  • list item
  • list item
  • list item
  • list item
  • list item

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
select by class
var products = $('#products-list .product, #products-list-2 .product, #products-list-3 .product');
pending…
multiple id selection
var products = $('.product');
pending…

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

Compare results of other browsers

0 comments

Add a comment