getElementById vs. querySelector (v165)

Revision 165 of this benchmark created on


Description

Compare the speed of getElementById to querySelector

Preparation HTML

<p id="foo">Foo</p>
<p id="bar">Bar</p>
<p id="baz">Baz</p>

  };
</script>

Setup

Benchmark.prototype.setup = function() {
    <script src="http://code.jquery.com/jquery-1.11.3.min.js">

Test runner

Ready to run.

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

Revisions

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