querySelectorAll vs getElementsByTagName (v146)

Revision 146 of this benchmark created on


Preparation HTML

<main id="content">
<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>
</main>

Test runner

Ready to run.

Testing in
TestOps/sec
querySelectorAll (tag)
var nodes = document.querySelectorAll('main')
ready
getElementsByTagName
var nodes = document.getElementsByTagName('main')
ready
querySelector (tag)
var nodes = document.querySelector('main')
ready
querySelector (id)
var nodes = document.querySelector('#content')
ready
querySelectorAll (id)
var nodes = document.querySelector('#content')
ready
getelementbyid
var nodes = document.getElementById('content')
ready

Revisions

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