jQuery vs querySelectorAll (v37)

Revision 37 of this benchmark created by Yuri on


Preparation HTML

<!doctype html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
</head>
<body>
<ul id="list">
<li>
<ul class="sublist">
<li>
item1
</li>
<li>
item2
</li>
</ul>
</li>
<li>
<ul class="sublist">
<li>
item1
</li>
<li>
item2
</li>
</ul>
</li><li>
<ul class="sublist">
<li>
item1
</li>
<li>
item2
</li>
</ul>
</li><li>
<ul class="sublist">
<li>
item1
</li>
<li>
item2
</li>
</ul>
</li>
</ul>
</body>
</html>

Test runner

Ready to run.

Testing in
TestOps/sec
jquery
$(".sublist").addClass("newClass");
ready
querySelectorAll
var nodes = document.querySelectorAll(".sublist");
for (var x = 0; x < nodes.length; x++)
  nodes[x].classList.add("newClass");
ready

Revisions

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