+ 3
Is it a good practice to use javascript instead css for animations?
scope of css and javascript
4 Answers
+ 7
It's adviced to use Css instead JS for all you can do by this way, for two mainly reasons:
- JS could be unavailable or disabled by user
- Css effects and animations are more efficient than handling them with JS in most of case, as JS execution is synchrone on a mono thread/processus: by the way, the more you have to handle stuff with JS, the more you will overload the process and get inneficiency, in addition to add page load time, rather than Css transitions and animations are handling directly by the browser, so optimize DOM interaction and memory consumption and most importantly, uses the GPU to improve performance, letting your other JS code having more ressources :P
+ 2
it's safe to use CSS, Javascript may be disabled on the user's browser.
+ 1
Yes, it's really usefull to create javascript animations. For exemple, when the player win a game in a web videogame, it's easy to create a js animation.