translate3d vs translate XY vs css left/top using percentage sized layout (v102)

Revision 102 of this benchmark created by micha.com on


Preparation HTML

<div id="elem" style="position: relative; background:#ccc; width:10%; height:10%;"></div>
<script>
  var elem = document.getElementById("elem");
  var style = elem.style;
</script>

Test runner

Ready to run.

Testing in
TestOps/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;
  style.transform = transform;
}
ready
translateX/Y
var x = y = 0;
for (var i = 100; i--;) {
  x = i;
  y = i * 5;
  var transform = 'translate(' + x + 'px, ' + y + 'px)';
  style.MozTransform = transform;
  style.WebkitTransform = transform;
  style.OTransform = transform
  style.transform = transform;
}
ready
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';
}
ready

Revisions

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