Zepto vs. jQ vs. jQmobi vs. raw

JavaScript performance comparison

Revision 124 of this test case created

Info

Zepto vs. jQuery vs. jQmobi vs. raw JS for getting an element by id (using latest versions, hosted on cl.ly)

Preparation code

<script src="http://f.cl.ly/items/0t3w1Z2R2L2s0J2D2Q2q/zepto.min.js">
</script>
<script src="http://f.cl.ly/items/2e2P0m3d1Q2U3w01230Y/jq.mobi.min.js">
</script>
<script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js">
</script>
<script src="http://xuijs.com/downloads/xui-2.3.2.min.js">
</script>
<script src="http://jsrun.it/damele0n/tuMO/js">
</script>
<script src="http://jsrun.it/damele0n/tQkX/js"></script>

<div id="asdf">
</div>
<script>
Benchmark.prototype.setup = function() {
    function el(string) {
      if (string.indexOf('#') === 0) {
        return document.getElementById(string.substr(1, string.length));
      }
    }
   
    //to be fair, I'll wrap getElementById in a function and return the object
   
    function byId(id) {
      return document.getElementById(id);
    }
   
    var boolean = true;
};
</script>

Preparation code output

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Zepto
Zepto('#asdf')
pending…
jQuery
jQuery('#asdf')
pending…
jQMobi
jq('#asdf')
pending…
Raw/baseline
byId('asdf')
pending…
Wrapped Raw
el('#asdf')
pending…
Straight getElementById
document.getElementById('asdf')
pending…
XUI
x$('#asdf')
pending…
querySelector
document.querySelectorAll('#asdf')
pending…
Riddle.js
r("#asdf")
pending…
kQuery
uu.query("#asdf");
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. Here’s a list of current revisions for this page:

0 comments

Add a comment