jQuery 1.x vs 2.x (v13)

Revision 13 of this benchmark created by m_gol on


Preparation HTML

<script src="//code.jquery.com/jquery-git1.js">
</script>
<script>
  jQ1 = jQuery.noConflict();
</script>
<script src="//code.jquery.com/jquery-git2.js">
</script>
<script>
  jQ2 = jQuery.noConflict();
</script>
<div id="wrapper">
</div>

Setup

jQ2("#wrapper").html('\n\
    <div id="idSelector" style="display: none;">\n\
      <div class="classSelector">\n\
        <div id="find">\n\
          <div id="cssGetter" style="color: black;">\n\
            <div id="cssSetter" style="color: black;">\n\
              <ul id="iteration">\n\
                <li>\n\
                  <div id="editablearea">\n\
                  </div>\n\
                </li>\n\
                <li>\n\
                  <p>\n\
                </li>\n\
                <li>\n\
                  <input type="checkbox">\n\
                </li>\n\
                <li>\n\
                  <h>\n\
                  </h>\n\
                </li>\n\
                <li>\n\
                  <table>\n\
                    <thead>\n\
                    </thead>\n\
                    <tbody>\n\
                    </tbody>\n\
                  </table>\n\
                </li>\n\
                <li>\n\
                  <textarea>\n\
                  </textarea>\n\
                </li>\n\
                <li>\n\
                  <span>\n\
                  </span>\n\
                </li>\n\
              </ul>\n\
            </div>\n\
          </div>\n\
          <div>\n\
          </div>\n\
        </div>\n\
      </div>\n\
    </div>\n\
    ');
    
    function testcase(_$) {
      var ti = _$("#iteration").clone().html();
      _$("#iteration li").each(function(i, e) {
        _$("#idSelector").find("table").append('<tr></tr>')
      });
      _$("#idSelector").find('table').empty();
      _$(".classSelector").toggleClass('test').data('ts', '3').attr('test', 'test');
      _$('#idSelector input').is(':checked');
      _$('#idSelector :checkbox').is(':visible');
      _$('#idSelector [type="checkbox"]').change();
    
      _$("#editablearea").text(ti).html(ti).empty();
      _$("#cssGetter").css("color");
      _$("#cssSetter").css("color", "green").css("color", "red");
      _$("#idSelector #iteration li").closest('ul');
      _$("#idSelector #iteration li").filter(":first").next().end();
      _$("#idSelector #iteration li").filter(":last").prev().parent();
    };

Teardown


    jQ2("#wrapper").empty();
  

Test runner

Ready to run.

Testing in
TestOps/sec
1.x
testcase(jQ1);
ready
2.x
testcase(jQ2);
ready

Revisions

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