querySelectorAll vs getElementsByTagName (v33)

Revision 33 of this benchmark created on


Description

Trying to force a lookup of the nodeList by adding .length

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>

Setup

var ul = document.querySelector('ul');

Test runner

Ready to run.

Testing in
TestOps/sec
querySelectorAll
var nodes = document.querySelectorAll('a'),
nodelength = nodes.length;
ready
getElementsByTagName
var nodes = ul.getElementsByTagName('a'),
nodelength = nodes.length;
ready
localized querySelectorAll
var nodes = ul.querySelectorAll('a'),
nodelength = nodes.length;
ready

Revisions

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