jQuery 1.4 vs 1.8 (v7)

Revision 7 of this benchmark created on


Description

Ref. http://jsperf.com/jquery-15-unique-traversal

Preparation HTML

<script src="//code.jquery.com/jquery-1.4.4.min.js">
</script>
<script>
  var $14 = jQuery.noConflict();
</script>
<script src="//code.jquery.com/jquery-1.8.2.min.js">
</script>
<script>
  var $18 = jQuery.noConflict();
</script>

<input id="val" type="text" value="foo">

<div id="children" style="display:none;"></div>
<script>
  var i, j, html = ""; 
  for (j = 0; j < 20; j++) {
   html += "<div class='children'>";
   for (i = 0; i < 5; i++) {
    html += "<div>abc</div><div>012</div>";
   }
   html += "</div>";
  }
 
  document.getElementById("children").innerHTML = html;
</script>

<div id="id-outer">
  <div id="id-inner">
  </div>
</div>

Setup

var $14val = $14('#val');
    var $18val = $18('#val');
    
    var $14children = $14(".children");
    var $18children = $18(".children");
    
    var $14outer = $14('#id-outer');
    var $18outer = $18('#id-outer');

Test runner

Ready to run.

Testing in
TestOps/sec
1.4 .val()
$14val.val();
ready
1.8 .val()
$18val.val();
ready
1.4 .children()
$14children.children();
ready
1.8 .children()
$18children.children();
ready
1.4 .find("#child")
$14outer.find('#id-inner');
ready
1.8 .find("#child")
$18outer.find('#id-inner');
ready
1.4 $("#id")
$14('#id-inner');
ready
1.8 $("#id")
$18('#id-inner');
ready

Revisions

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