Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GSAP Performance & Structure

GSAP claims to use HTML5 to perform outstanding animations for web use, but says clearly in the their article on Greensock.com that it does not use the canvas frame work in html5. It is clear that they are using Javascript from the provided script, but it is very confusing to interpret. In what other way would they use html5 animations without the canvas? And if they do use pure HTML5 does this mean that HTML5 animations are significantly faster than CSS, jQuery, and Javascript?

like image 776
StoneAgeCoder Avatar asked Feb 12 '23 16:02

StoneAgeCoder


1 Answers

There's not such thing as "html5 animations".

There are, mainly, CSS3 animations (with either CSS transition or CSS animations) and Javascript animations.

CSS3 animations are generally well optimised (with a few quirks) but lacks support (old IEs) and flexibility (you'll have to use JavaScript to tweak them.) They're best for hover effect (with transitions) or basic animations.

JavaScript transition used to be based on a setInterval. A timed loop, and inside this loop the styles are changed. JQuery does this, and not very well.

Recently, Window.requestAnimationFrame() was introduced to replace these setInterval animations. Support is limited (old IEs), performance is top notch (because the browser can skip frames), and it's always style updates inside.

What GSAP does is using this requestAnimationFrame() while optimizing for less repaints and adding a lot of useful features (reverse, timelines, stagger...) On basic animations, you can achieve the same performances with CSS3 or your own JS code... if you know what to do.

There are also others animations (canvas, svg... event webgl) but more specialized.

like image 95
mddw Avatar answered Feb 15 '23 05:02

mddw