querySelectorAll vs getElementsByTagName (v147)

Revision 147 of this benchmark created on


Preparation HTML

<div>
  <ul>
    <li><a href="#">item 1</a></li>
    <li class="klass"><a href="#">item 2</a></li>
    <li><a href="#">item 3</a></li>
  </ul>
</div>

Setup

var list = document.getElementsByTagName("ul")[0];

Test runner

Ready to run.

Testing in
TestOps/sec
querySelectorAll
var nodes = list.querySelectorAll('.klass');
ready
getElementsByTagName
var nodes = list.getElementsByClassName('klass');
ready

Revisions

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