getElementById VS jQuery('#id') (v32)

Revision 32 of this benchmark created on


Preparation HTML

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

Setup

var $_ = function(n) {
      return $(document.getElementById(n));
    }

Test runner

Ready to run.

Testing in
TestOps/sec
getElementById
var a = document.getElementById('foo123');
 
ready
jQuery
var a = jQuery('#foo123');
ready
Wrap
var a = $(document.getElementById('foo123'));
ready
My Wrap
var a = $_('foo123');
ready

Revisions

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