querySelector vs getElementsByTagName (v115)

Revision 115 of this benchmark created by Brian Griffin 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>
    <li><a href="#">item 4</a></li>
    <li><a href="#">item 5</a></li>
    <li><a href="#">item 6</a></li>
    <li><a href="#">item 7</a></li>
    <li><a href="#">item 8</a></li>
    <li><a href="#">item 9</a></li>
  </ul>
</div>

Test runner

Ready to run.

Testing in
TestOps/sec
querySelector
var nodes = document.querySelector('a')
ready
getElementsByTagName
var nodes = document.getElementsByTagName('a')[0]
ready

Revisions

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