jQuery vs JavaScript Performance Comparison ($.each vs. for)) (v91)

Revision 91 of this benchmark created by Rick Jelier on


Preparation HTML

<table>
  <tr>
    <td>Name</td>
    <td>Email</td>
    <td>Company</td>
  </tr>
  <tr>
    <td>Name</td>
    <td>Email</td>
    <td>Company</td>
  </tr>  
  <tr>
    <td>Name</td>
    <td>Email</td>
    <td>Company</td>
  </tr>
</table>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery each
$.each($('tr'), function(key, val) {
  $(val).addClass('visited');
})
ready
JavaScript for
var elements = document.querySelectorAll('tr');

for (var i = elements.length - 1; i >= 0; i--) {
  elements[i].setAttribute("class", "visited")
}
ready

Revisions

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