translate3d vs translate vs css left/top vs css margin

JavaScript performance comparison

Revision 96 of this test case created

Preparation code

<div id="guide" style="width:100px;height:100px; overflow:hidden"><div id="elem" style="width:100000px; height=100000px">a</div></div>
<script>
  var elem = document.getElementById("elem");
  var wrapper = document.getElementById("guide");
  var style = elem.style;
</script>

Preparation code output

a

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 = '';

for (var i = 200; i--;) {
  x = i * 5;
  t = 'translate3d(' + x + 'px, 0, 0)';
  style.webkitTransform = t;
}
pending…
translate
var x = 0,
    t = '';

for (var i = 200; i--;) {
  x = i * 5;
  t = 'translateX(' + x + 'px)';
  style.webkitTransform = t;
}
pending…
Test 3
var x = 0,
    t = '';

for (var i = 200; i--;) {
  x = i * 5;
  wrapper.scrollLeft = x;
}
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