querySelectorAll vs getElementsByTagName (v90)

Revision 90 of this benchmark created by karthick on


Preparation HTML

<div>
  <ul>
    <li><a class='first listItem' href="#">item 1</a></li>
    <li><a href="#">item 2</a></li>
    <li><a href="#">item 3</a></li>
  </ul>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

Test runner

Ready to run.

Testing in
TestOps/sec
querySelectorAll
var nodes = document.querySelectorAll('a')
ready
getElementsByTagName
var nodes = document.getElementsByTagName('a')
ready
jquery
var nodes = jQuery('a')
ready
jquery
var nodes = $('a')
ready
jQuery ClassName
var nodes = $('.first')
ready
getElementByClassName
var nodes = document.getElementsByClassName('.first')
ready
QuerySelectorAll
var nodes = document.querySelectorAll('first')
ready
native code
var nodes = document.querySelectorAll('.first.listItem')
ready
jQuery
var nodes = jQuery('.first.listItem')
ready

Revisions

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