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

Revision 18 of this benchmark created on


Preparation HTML

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

Test runner

Ready to run.

Testing in
TestOps/sec
querySelector Class
document.querySelector("#foo .bar span");
ready
querySelectorAll Class
document.querySelectorAll("#foo .bar span");
ready
querySelector Id
document.querySelector("#foo");
ready
querySelectorAll Id
document.querySelectorAll("#foo");
ready
getelementid
document.getElementById("#foo");
ready

Revisions

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