HTML5 Zone is brought to you in partnership with:

John Esposito edits Refcardz at DZone, while writing a dissertation on ancient Greek philosophy and raising two cats. In a previous life he was a database developer and network administrator. John is a DZone Zone Leader and has posted 320 posts at DZone. You can read more from them at their website. View Full User Profile

CSS3 Transitions vs. jQuery Animate: Performance

01.20.2012
| 16121 views |
  • submit to reddit

Rich Bradshaw has written a detailed tutorial series on CSS Transitions, Transforms, and Animation.

That alone is worth reading; but in case you weren't convinced, Rich also put together a little (and maybe a little unfair) performance comparison:

A head to head comparison of CSS transitions and jQuery's animate. Rather than setting a timer to run repeatedly, transitions are handled natively by the browser. In my rather unscientific testing, transitions are always quicker, running with a higher frame rate, especially with high numbers of elements. They also have the advantage that colours can be animated easily, rather than having to rely on plugins.

 
The results probably won't surprise you, and the conclusion inevitable ('use CSS3 for animation when you can') but Rich's analysis (scroll down), using the Timeline view in the Webkit Inspector, is pretty neat:

 
(Actually, the Timeline is pretty neat, period. I didn't know about it until now..sweet.)

So check out Rich's test and performance discussion, and maybe use Webkit Inspector's Timelinefor performance fine-tuning in the future.

Tags: