querySelectorAll vs getElementsByTagName (v17)

Revision 17 of this benchmark created on


Preparation HTML

<div>
  <ul>
    <li><a href="#">item 1</a></li>
    <li><a href="#">item 2</a></li>
    <li><a href="#">item 3</a></li>
  </ul>
</div>
<script>
  function makeArray(obj) {
   var arr = [];
   for (var i = obj.length; i--;)
   arr[i] = obj[i];
   return arr;
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
querySelectorAll
var nodes = document.querySelectorAll('a')
ready
byTagName live
var nodes = document.getElementsByTagName('a')
ready
byTagName static
var nodes = makeArray(document.getElementsByTagName('a'));
ready

Revisions

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