translate3d vs translate XY vs css left/top

JavaScript performance comparison

Revision 19 of this test case created

Preparation code

<div id="elem" style="position: absolute; 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 = 0,
    t = '';

style.WebkitTransition ='all 250ms cubic-bezier(0.85,0,0.15,1)';
style.MozTransition ='all 250ms cubic-bezier(0.85,0,0.15,1)';
style.OTransition ='all 250ms cubic-bezier(0.85,0,0.15,1)';
style.msTransition ='all 250ms cubic-bezier(0.85,0,0.15,1)';
style.transition ='all 250ms cubic-bezier(0.85,0,0.15,1)';

for (var i = 20; i--;) {
  x = i * 5;
  t = 'translate3d(' + x + 'px, 0, 0) rotate(' + x + 'deg)';
  style.WebkitTransform = t;
  style.MozTransform = t;
  style.OTransform = t;
  style.msTransform = t;
  style.transform = t;
}
pending…
translate
var x = 0,
    t = '';

style.WebkitTransition ='all 250ms cubic-bezier(0.85,0,0.15,1)';
style.MozTransition ='all 250ms cubic-bezier(0.85,0,0.15,1)';
style.OTransition ='all 250ms cubic-bezier(0.85,0,0.15,1)';
style.msTransition ='all 250ms cubic-bezier(0.85,0,0.15,1)';
style.transition ='all 250ms cubic-bezier(0.85,0,0.15,1)';

for (var i = 20; i--;) {
  x = i * 5;
  t = 'translate(' + x + 'px, 0) rotate(' + x + 'deg)';
  style.WebkitTransform = t;
  style.MozTransform = t;
  style.OTransform = t;
  style.msTransform = t;
  style.transform = t;
}
pending…
left
var x = 0,
    t = '';

style.WebkitTransition ='all 250ms cubic-bezier(0.85,0,0.15,1)';
style.MozTransition ='all 250ms cubic-bezier(0.85,0,0.15,1)';
style.OTransition ='all 250ms cubic-bezier(0.85,0,0.15,1)';
style.msTransition ='all 250ms cubic-bezier(0.85,0,0.15,1)';
style.transition ='all 250ms cubic-bezier(0.85,0,0.15,1)';

for (var i = 20; i--;) {
  x = i * 5;
  t = x + 'px';
  style.left = t;
  t = 'rotate(' + x + 'deg)';
  style.WebkitTransform = t;
  style.MozTransform = t;
  style.OTransform = t;
  style.msTransform = t;
  style.transform = t;
}
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