getElementById vs querySelector

Benchmark created by Silver_Clash on


Preparation HTML

<p id="foo">Foo</p>

Test runner

Ready to run.

Testing in
TestOps/sec
getElementById
document.getElementById("foo");
ready
querySelector("#foo")
document.querySelector("#foo");
ready
querySelector("[id=elem]");
document.querySelector("[id=foo]");
ready

Revisions

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