getElementById vs. querySelector (v128)

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

Test runner

Ready to run.

Testing in
TestOps/sec
getElementById
var foo = document.getElementById("foo");
var bar = document.getElementById("bar");
var baz = document.getElementById("baz");
ready
querySelector
var bar = document.querySelector("[]");
ready

Revisions

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