Loop De Loop (with class)

JavaScript performance comparison

Revision 7 of this test case created by Ben

Preparation code

<ol style="display: none;"></ol>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js">
</script>
<script>
Benchmark.prototype.setup = function() {
    for ( var i = 0; i < 500; i++ ) {
      $( "<li class='le-li'>first</li>" ).appendTo( "ol" );
    }
     
   
};

Benchmark.prototype.teardown = function() {
    $("ol").html("");
};
</script>

Preparation code output

    Test runner

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

    Java applet disabled.

    Testing in unknown unknown
    Test Ops/sec
    jquery chained attr()
    $('.le-li')
      .attr("alt", "myAlt")
      .attr("title", "myTitle")
      .attr("data-test1", "test1")
      .attr("data-test2", "test2")
      .attr("data-test3", "test3")
      .attr("data-test4", "test4")
      .attr("data-test5", "test5")
      .attr("data-test6", "test6")
      .attr("data-test7", "test7")
      .attr("data-test8", "test8");
    pending…
    jquery single large attr()
    $('.le-li').attr({
      "alt": "myAlt",
      "title": "myTitle",
      "data-test1": "test1",
      "data-test2": "test2",
      "data-test3": "test3",
      "data-test4": "test4",
      "data-test5": "test5",
      "data-test6": "test6",
      "data-test7": "test7",
      "data-test8": "test8"
    });
    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. Here’s a list of current revisions for this page:

    0 comments

    Add a comment