Take the 2-minute tour ×

I'm wondering whether there is a performance difference between using different CSS properties to translate an element. Some properties fit different situations differently.

You can translate an element with following properties: transform, top/left/right/bottom and margin-top/left/right/bottom

In the case where you do not utilize the transition CSS property for the translation but use some form of a timer (setTimeout, requestAnimationFrame or setImmediate) or raw events, which is the most performant–which is going to make for higher FPS rates?

share|improve this question
It seems that your post title contradicts the question you are asking? –  Laykes Nov 19 '12 at 22:51
add comment

1 Answer

Your milage is always going to vary between different browers. I don't think that you can accurately say one solution is going to always be the best cross browser, but what you can accurately rely on, is that anything that uses your GPU is going to be faster. When you animate using a setTimeout, the browser does all of the crunching in memory and through the CPU. Additionally, it doesn't really know that the intended animation is suposed to be smooth.

Depending on which version of your browser, you will also find that GPU acceleration can be hit or miss. For example, up until last year, a common trick to ensure that webkit based browsers always used GPU accelleration was to do a kind of "type hint" where you would set the property to be -webkit-transform: translateZ(0)

Another point to add however, is what does "performant" actually mean for you? Does it mean visually performant, which means smooth? In which case you wouldn't want to use setTimeout, because you can't realistically get that "smoothness". So where possible, you would want to use transitionining through CSS (and rely on GPU accelleration where avaialble).

But what if you mean "performant" in terms of battery life on your device. In which case you would probably want to use requestAnimationFrame.

Why should I use it?


Reference : requestAnimationFrame for smart animating

Next up, "performant" might mean time-spent for you. I know that personally, I can be most performant if I use CSS animations, and use them whereever possible.

This article will be a useful read for you:


share|improve this answer
Also, if you don't like client-side performance optimization now, wait about 5 minutes for everything to change. –  Erik Reppen Dec 20 '12 at 5:03
add comment

Your Answer


