translate3d vs translate XY vs css left/top (v73)

Revision 73 of this benchmark created by nomiadcode on


Preparation HTML

<div id="elem" style="position: absolute; background:#ccc; width:10px; height:10px; transform:translate3d(0px,0px,0px); -webkit-backface-visibility:hidden;"></div>
<script>
  var elem = document.getElementById("elem");
  var style = elem.style;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
translate3d
var rnd = Math.random();
x = 10 * rnd;
y = 10 * rnd;
var transform = 'translate3d(' + x + 'px, ' + y + 'px, 0px)';
if (style.WebkitTransform) {
  style.WebkitTransform = transform;
} else if (style.MozTransform) {
  style.MozTransform = transform;
} else {
  style.OTransform = transform;
}
ready
translateX/Y
var rnd = Math.random();
x = 10 * rnd;
y = 10 * rnd;
var transform = 'translateX(' + x + 'px) translateY(' + y + 'px)';
style.MozTransform = transform;
style.WebkitTransform = transform;
style.OTransform = transform
ready
css left/top
var rnd = Math.random();
x = 10 * rnd;
y = 10 * rnd;
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.