JavaScript Selectors

JavaScript performance comparison

Revision 2 of this test case created by Nathan

Preparation code

<div class="class1 class2"></div>
<span class="class1 class2"></span>
<div class="class1 class2">
  <button id="btn-test" class="btn-class">#btn-test</button>
  <p class="class1"></p>
  <div class="class2"></div>
</div>

<script src="https://fireboltjs.com/firebolt.min.js"></script>
<script src="https://zeptojs.com/zepto.min.js"></script>
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
    

Preparation code output

<div class="class1 class2"></div> <span class="class1 class2"></span> <div class="class1 class2"> <button id="btn-test" class="btn-class">#btn-test</button> <p class="class1"></p> <div class="class2"></div> </div>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Firebolt
Firebolt('#btn-test');
Firebolt('.class1');
Firebolt('.class1.class2');
Firebolt('div');
Firebolt('div.class2');
Firebolt('div > button');
pending…
Zepto
Zepto('#btn-test');
Zepto('.class1');
Zepto('.class1.class2');
Zepto('div');
Zepto('div.class2');
Zepto('div > button');
pending…
jQuery
jQuery('#btn-test');
jQuery('.class1');
jQuery('.class1.class2');
jQuery('div');
jQuery('div.class2');
jQuery('div > button');
pending…

Compare results of other browsers

Revisions

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

0 Comments