translate3d vs translate XY vs css left/top

JavaScript performance comparison

Revision 24 of this test case created

Preparation code

<div id="elem" style="position: relative; background:#ccc; width:10px; height:10px;"></div>
<script>
  var elem = document.getElementById("elem");
  var style = elem.style;
</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
translate3d
var x = y = 0;
for (var i = 100; i--;) {
 x = i;
 y = i * 5;
 var transform = 'translate3d(' + x + 'px, ' + y + 'px, 0)';
 style.MozTransform = transform;
 style.WebkitTransform = transform;
 style.OTransform = transform;
}
pending…
translateX/Y
var x = y = 0;
for (var i = 100; i--;) {
 x = i;
 y = i * 5;
 var transform = 'translateX(' + x + 'px) translateY(' + y + 'px)';
 style.MozTransform = transform;
 style.WebkitTransform = transform;
 style.OTransform = transform
}
pending…
css left/top
var x = y = 0;
for (var i = 100; i--;) {
 x = i;
 y = i * 5;
 style.left = x + 'px';
 style.top = y + 'px';
}
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:

2 comments

Mason commented :

You must be doing something wrong. I'm not sure what, but on every webkit device I own translate3d is visibly faster/smoother.

The exact same call with left/top will quite obviously visually stutter and jerk as opposed to a translate3d call. I'm not sure what is being measured here, but whatever it is simply isn't right.

Adrian commented :

This page only TEST for js runtime, IT have nothing to do with rendering runtime ~ so .............

Add a comment