zepto vs jquery - selectors

JavaScript performance comparison

Revision 23 of this test case created by Zachary Lym

Preparation code

<script src="https://www.cinsoft.net/mylib099-min.js"></script>
<script src="https://code.jquery.com/jquery-2.0.3.min.js"></script>
<script src="http://zeptojs.com/zepto.min.js"></script>


<div id="rsvp" class="view" data-view-title="RSVPs">
    <div class="content"></div>
</div>
<div id="chapter_004" class="view" data-view-title="Splendid Corgi Consortium">
    <div class="content"></div>
</div>
      
<script>
Benchmark.prototype.setup = function() {
  = function id(id) {
    return document.getElementById(id);
  }
  var native = function(e) {
    return document.querySelectorAll(e);
  };
  
  native.prototype.id = function(id) {
    //raw document.getElementById(id) is slightly faster
    return document.getElementById(id);
  };

};
</script>

Preparation code output

<script src="https://code.jquery.com/jquery-2.0.3.min.js"></script> <script src="http://zeptojs.com/zepto.min.js"></script> <div id="rsvp" class="view" data-view-title="RSVPs"> <div class="content"></div> </div> <div id="chapter_004" class="view" data-view-title="Splendid Corgi Consortium"> <div class="content"></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
Zepto ID
Zepto('#chapter_004')
pending…
jQuery2 ID
jQuery('#chapter_004')
pending…
Native querySelectorAll
native('#chapter_004');
pending…
Native getElementById
native.id('chapter_004')
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