animate js vs jquery (v2)

Revision 2 of this benchmark created on


Preparation HTML

<style>
#a {
  width: 20px;
  height: 20px;
  position: absolute;
  border: 1px solid;
  top: 0;
  left: 0;
}
</style>
<div id="a">a</div><script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
function animate(object, property, start_value, end_value, time) {
  var frame_rate = 0.06; // 60 FPS
  var frame = 0;
  var delta = (end_value - start_value) / time / frame_rate;
  var handle = setInterval(function() {
    frame++;
    var value = start_value + delta * frame;
    object.style[property] = value + "px";
    if (value == end_value) {
      clearInterval(handle);
    }
  }, 1 / frame_rate);
}
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Animate JS
animate(document.getElementById("a"),
        "top",
        0, 
        100,
        1000
        );
ready
Animate jQuery
$('#a').animate({top:100}, 1000);
ready

Revisions

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