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

Revision 133 of this benchmark created by boyboy1989 on


Preparation HTML

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
! function($) {
   $.id = function(id) {
      return $(document.getElementById(id));
   }
}(jQuery);

function getObjectById(id){
        return jQuery(document.getElementById(id));
}
</script>
<div id="foo">
  Test
</div>

Test runner

Ready to run.

Testing in
TestOps/sec
$.id
$.id('foo')
ready
getObjectById
getObjectById('foo')
ready
$(document.getElementById())
$(document.getElementById('foo'))
ready
jQuery
$('#foo')
ready

Revisions

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