document.getElementById VS Jquery $('#') (v14)

Revision 14 of this benchmark created on


Description

Comparison for $('#idSelector') VS document.getElementById('');

Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
</script>
<script src="http://zeptojs.com/zepto.min.js"></script>
<p id="foo">
  Test
</p>

Setup

var doc = {id : document.getElementById, class: document.getElementByClassName}
    var m = function(id){
      return document.getElementById(m)
    }
    
    function caller(id){
    doc.id.call(document, id);
    }

Test runner

Ready to run.

Testing in
TestOps/sec
test1
caller('#foo');
ready
Test2
m('#foo');
ready
test4
doc.id.call(document,'foo');
ready

Revisions

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