querySelector vs querySelectorAll vs getElementById vs getElementsByClassName vs getElementsByTagName (v11)

Revision 11 of this benchmark created on


Preparation HTML

<p id="foo" class="foo">
  bar
</p>

Test runner

Ready to run.

Testing in
TestOps/sec
querySelector
document.querySelector("#foo");
ready
querySelectorAll
document.querySelectorAll("#foo")[0];
ready
getElementById
document.getElementById("foo");
ready
getElementsByClassName
document.getElementsByClassName("foo")[0];
ready
getElementsByTagName
document.getElementsByTagName("p");
ready

Revisions

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