cached jquery selector vs. sprintjs selector

JavaScript performance comparison

Test case created by Lars

Preparation code

<script src="https://sprintjs.com/prod"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>

<div class="myElement">
 <span></span>
 <span></span>
 <span></span>
 <span></span>
 <span></span>
 <span></span>
</div>
    

Preparation code output

<div class="myElement"> <span></span> <span></span> <span></span> <span></span> <span></span> <span></span> </div>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
jQuery
$myElement = jQuery('.myElement span');
$myElement.each(function() {
  $myElement.find(this).css('color', 'green');
});
pending…
Sprint.js
$myElement = Sprint('.myElement span');
$myElement.each(function(index) {
  $myElement.find(this).css('color', 'green');
});
pending…

Compare results of other browsers

Revisions

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

0 Comments