querySelector vs getElementById

Benchmark created on


Preparation HTML

<span id="hello">Hello</span>

Test runner

Ready to run.

Testing in WebKit 537.36 / undefined
TestOps/sec
Query selector
const element = document.querySelector("#hello");
ready
Get element by ID
const element = document.getElementById("hello");
ready

Revisions

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