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

Revision 68 of this benchmark created on


Preparation HTML

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

<ul>
   <li><a href="#">Page 1</a></li>
   <li><a href="#">Page 2</a></li>
   <li><a href="#">Page 3</a></li>
   <li><a href="#">Page 4</a></li>
</ul>

</p>

Test runner

Ready to run.

Testing in
TestOps/sec
querySelector
document.querySelector("#foo a");
ready
querySelectorAll
document.getElementById('foo').querySelectorAll("a");
ready

Revisions

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