getElementById vs. querySelector (v14)

Revision 14 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>

Setup

< script src = "//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" > < /script>

Test runner

Ready to run.

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

Revisions

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