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

Revision 20 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
getElementsByClassName
document.getElementsByClassName("bar");
ready
querySelectorAll
document.querySelectorAll(".bar");
ready

Revisions

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