jQuery Animation : step performance

JavaScript performance comparison

Revision 2 of this test case created

Preparation code

<div id="tester">Hi</div>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
 
<script>
Benchmark.prototype.setup = function() {
    var x = 100;
};

Benchmark.prototype.teardown = function() {
    $('#tester').stop().css({
      "opacity": 1,
      "width":200
    });
};
</script>

Preparation code output

Hi

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Usual
$('#tester').animate({
  "opacity":50/x,
  "width":x
},500)
pending…
Step
$('#tester').animate({
  "customRatio": x,
},{
  "duration": 500,
  "step": function(a,b){
    if (b.prop = "customRatio") {
      $(this).css({
        "opacity":50/a,
        "width":a
      })
    }
  }
})
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