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

Revision 69 of this benchmark created on


Preparation HTML

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

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

</p>

Test runner

Ready to run.

Testing in
TestOps/sec
querySelectorAll
document.querySelectorAll("[colored]");
ready
getElementsByClassName
document.getElementsByClassName('colored');
ready

Revisions

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