getElementById-vs-querySelector

Benchmark created by Run on


Description

document.getElementById -vs- document.querySelector

Preparation HTML

<div>
<div id="select">

which is faster?

</div>

</div>

Test runner

Ready to run.

Testing in
TestOps/sec
document.getElementById
document.querySelector("#select");
ready
document.querySelector
document.getElementById("select");
 
ready

Revisions

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