getElementById vs. querySelector vs jQuery (v166)

Revision 166 of this benchmark created on


Description

Compare the speed of getElementById, querySelector and jQuery.

Preparation HTML

<script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
<p id="foo">Foo</p>
<p id="bar">Bar</p>
<p id="baz">Baz</p>

Test runner

Ready to run.

Testing in
TestOps/sec
getElementById
var foo = document.getElementById("bar");
ready
querySelector
var bar = document.querySelector('#bar');
ready
jQuery 2.1
var baz = $('#bar');
ready

Revisions

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