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

Revision 71 of this benchmark created by Jacob Gable on


Description

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

Preparation HTML

<script src="//cdnjs.cloudflare.com/ajax/libs/zepto/1.0rc1/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.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;

Test runner

Ready to run.

Testing in
TestOps/sec
Zepto
Zepto('#asdf')
ready
jQuery
jQuery('#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.