jQuery 1.4 vs 1.3 vs 1.2 vs 1.1 performance test

Benchmark created by niu tech on


Description

Let's test the different versions of jQuery library for: * selectors * DOM traversing * DOM manipulation * form serialization * events

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"></script>
<script type="text/javascript">var j4 = jQuery.noConflict();</script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"></script>
<script type="text/javascript">var j3 = jQuery.noConflict();</script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js"></script>
<script type="text/javascript">var j2 = jQuery.noConflict();</script>
<script src="//jqueryjs.googlecode.com/files/jquery-1.1.4.js"></script>
<script type="text/javascript">var j1 = jQuery.noConflict();</script>

<div id="test"> 
        <div class="testlink">
                <a href="#" id="linkone" title="test">test link</a>
        </div> 
        <div class="testmenu">
                <ul>
                        <li class="menuitem itemone">
                                <a href="#" title="item 1">menu item 1</a>
                        </li>
                        <li class="menuitem itemtwo">
                                <a href="#" title="item 2">menu item 2</a>
                        </li>
                        <li class="menuitem itemthree">
                                not clickable item 3
                        </li>
                </ul>
        </div>
</div>
<form action="" method="get">
        <p>
                <input type="hidden" name="a" value="abc" />
                <input type="hidden" name="b" value="1.0" />
                <input type="hidden" name="c" value="1" />
        </p>
</form>
<script>
  var selectors = ['body', 'div', 'body div', 'div a', 'div > a', 'div[class^=test]', 'div, li, a', '.menuitem', 'li.menuitem', '#linkone', 'div#test', 'a[title*=item]', 'a[title=test]', 'div:not(.testlink)', 'li:nth-child(even)', 'li:nth-child(odd)', 'li:last-child', 'li:first-child'];
  var htmlafter = '<a href="#" id="linktwo" title="test">test link 2</a>';
  var htmlappend = '<span> 1</span>';
  clickaction = function() {
   return $(this);
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery 1.4
for (var sel in selectors) {
 j4(sel);
}
j4('#linkone').parent().next().find('li').eq(0);
j4('#linkone').after(htmlafter).append(htmlappend);
j4('form').serialize();
j4('#linkone').click(clickaction);
ready
jQuery 1.3
for (var sel in selectors) {
 j3(sel);
}
j3('#linkone').parent().next().find('li').eq(0);
j3('#linkone').after(htmlafter).append(htmlappend);
j3('form').serialize();
j3('#linkone').click(clickaction);
ready
jQuery 1.2
for (var sel in selectors) {
 j2(sel);
}
j2('#linkone').parent().next().find('li').eq(0);
j2('#linkone').after(htmlafter).append(htmlappend);
j2('form').serialize();
j2('#linkone').click(clickaction);
ready
jQuery 1.1
for (var sel in selectors) {
 j1(sel);
}
j1('#linkone').parent().next().find('li').eq(0);
j1('#linkone').after(htmlafter).append(htmlappend);
j1('form').serialize();
j1('#linkone').click(clickaction);
ready

Revisions

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