querySelectorAll vs getElementsByTagName (v106)

Revision 106 of this benchmark created on


Preparation HTML

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

Test runner

Ready to run.

Testing in
TestOps/sec
querySelectorAll
var nodes = document.querySelectorAll('.can-see')
ready
getElementsByTagName
var result = [];
var nodes = document.getElementsByTagName('li');
for (var i = 0, l = nodes.length; i < l; i++ ) {
var node = nodes[i];
if (node.getAttribute('class')) {
result.push(node);
}
}
ready

Revisions

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