Zepto vs. jQ vs. raw JS Dom (v31)

Revision 31 of this benchmark created by Devin on


Description

Zepto vs. Jquery vs. raw JS for getting an element by id

Preparation HTML

<script src="//staging-ian.appmobi.com/game/zepto.min.js">
</script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<div id="asdf">
</div>

Setup

function el(string) {
      if (string.charAt(0) === '#') {
        return document.getElementById(string.substr(1, string.length));
      }
    }
    
    
    //to be fair, I'll wrap getElementById in a function and return the object
    var boolean = true;
    function byId(id) {
      if (boolean) return document.getElementById(id);
    }

Test runner

Ready to run.

Testing in
TestOps/sec
Jquery
$('#asdf')
ready
Zepto
$('#asdf')
ready
Raw/baseline
byId('asdf')
ready
Wrapped Raw
el('#asdf')
ready
Straight getElementById
document.getElementById('asdf')
ready

Revisions

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