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

Revision 23 of this benchmark created by Joe on


Description

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

Preparation HTML

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

Test runner

Ready to run.

Testing in
TestOps/sec
Javascript
document.getElementById('foo').innerHTML = "Hi";
ready
jQuery
$('#foo').innerHTML = "Hi";
ready
jQuery + JS
$(document.getElementById('foo')).innerHTML = "Hi";
ready
test4
var bar = document.getElementById('foo');
bar.innerHTML = "Hi";
ready
jquery .html()
$('#foo').html("Hi");
ready
jquery with vanilla .html()
$(document.getElementById('foo')).html("Hi");
ready

Revisions

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