getElementById vs. querySelectorAll (v3)

Revision 3 of this benchmark created on


Description

Compare the speed of getElementById to querySelectorAll

Preparation HTML

<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 bar = document.getElementById("bar");
ready
querySelectorAll
var bar = document.querySelectorAll("#bar");
ready
querySelector
var bar = document.querySelector("#bar");
ready
querySelectorAll (spec)
var bar = document.querySelectorAll("p#bar");
ready
querySelector (spec)
var bar = document.querySelector("p#bar");
ready

Revisions

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