jQuery animate VS CSS

JavaScript performance comparison

Test case created

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div id="container" style="background:silver, padding:10px"></div>
<script>
Benchmark.prototype.setup = function() {
    var divs=[],
        div = '<div class="tester" style="float:left; width: 20px; height: 20px; position:relative; background: none repeat scroll 0% 0% red; border:1px solid white;"></div>';
   
    for(var i=0; i<20; i++){
        divs[i] = div;
    }
   
    $(document).ready(function(){
    $('#container').html(divs.join(""));
    })
       
   
};
</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
animate
$('.tester').animate({left:-10, top:-5}, 0)
pending…
css
$('.tester').css({left:-10, top:-5})
pending…

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

Compare results of other browsers

0 comments

Add a comment