Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what's faster? CSS3 transitions or jQuery animations?

I'm working on an iPad HTML5 app and I've already implemented ontouch support to trigger events faster and I'm using jQuery to target the elements easier, but for the animations I'm using CSS3 transitions

What do you think is faster? using jQuery animations since I already have imported the library or use CSS3 transitions when targeting elements with jQuery?

like image 462
Moisés Olmedo Avatar asked Jun 11 '12 17:06

Moisés Olmedo


People also ask

Are CSS animations faster than JavaScript?

CSS has fairly good performance as it offloads animation logic onto the browser itself. This lets the browser optimize DOM interaction and memory consumption and most importantly, uses the GPU to improve performance. On the other hand, Javascript performance can range from reasonably faster to much slower than CSS.

Should I use transition or animation CSS?

CSS transitions are generally best for simple from-to movements, while CSS animations are for more complex series of movements. It's easy to confuse CSS transitions and animations because they let you do similar things. Here are just a few examples: You can visualize property changes.

Are CSS animations performant?

The fact is that, in most cases, the performance of CSS-based animations is almost the same as JavaScripted animations — in Firefox at least. Some JavaScript-based animation libraries, like GSAP and Velocity. JS, even claim that they are able to achieve better performance than native CSS transitions/animations.

Why do you use css3 transitions?

CSS transitions provide a way to control animation speed when changing CSS properties. Instead of having property changes take effect immediately, you can cause the changes in a property to take place over a period of time.


2 Answers

According to this link, jQuery animation is much slower then css animation.

Reason can be because jquery has to modify the props of the DOM element using timers and a loop. The CSS is part of the browser engine . which depends pretty much on hardware of system. You can also check that in profiling of Chrome or Firefox.

like image 96
Ashish Gupta Avatar answered Oct 06 '22 00:10

Ashish Gupta


CSS animations will almost always be faster.

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.

http://css.dzone.com/articles/css3-transitions-vs-jquery

Related Question: Performance of CSS Transitions vs. JS animation packages

like image 37
Cameron Martin Avatar answered Oct 05 '22 23:10

Cameron Martin