Javascript or CSS3?
- Started
- Last post
- 7 Responses
- boobs
These days a lot of basic animations can be done with CSS3. Is it better to do them with CSS3, or use plain old Javascript?
- instrmntl0
i like greensock.
- hereswhatidid0
Ideally you should be using Modernizr to detect support for the CSS3 elements and if they are not supported, fall back with JavaScript animations.
- d_rek0
Both are good options and fairly widely supported by all major browsers ATM...
Use whatever best suits your needs and/or you're more comfortable with.
- mekk0
Animations used for highlighting > CSS3
Animations used for critical layout decisions (branding etc..) > JS to be sure it works everywhere
- kingsteven0
css3 animation is keyframed css. so pretty basic stuff - it still requires webkit vendor prefixes (twice the work for simple animations or requires a js lib) and won't work in Internet Explorer < v10.
I guess there's an argument that not requiring javascript libraries makes the animations smaller and more embedable/ re-usable... Maybe there's an advantage for banner advertisements? or something distributable like that... In practice though... if you're dynamically loading CSS you're going to need to use JS DOM manipulation to maintain standards compatibility. So, you could end up keyframing CSS animations via jQuery by dynamically parsing SVG animation markup... or just use a JS animation lib or SVG in the first place!
IT DUNT REALLY MATTER
- fourth0
I really like using CSS3 transitions (mainly because I don't know JS all too well). The secret is to use a preprocessor like less or sass so you don't have to keep rewriting vendor prefixes.
For basic UI animations/transitions/effects at least....
- zaq0
CSS3 is better as far as performance. JS is better as far as browser suport
http://gsklee.im/post/5384933965…