...
/Choosing the Right Animation Technique
Choosing the Right Animation Technique
Let's cover some simple steps to choosing the right animation technique.
We'll cover the following...
Now, decision time. How should you choose between setInterval()
, requestAnimationFrame()
, or CSS to animate your page? The answer depends on how complex your animation is. In theory, CSS animations are more efficient performance-wise, but you can’t do everything with them.
Here’s how you might want to approach your decision:
-
Use
setInterval()
if the animation isn’t in real-time and should just happen at regular intervals. -
Favor CSS if the animation happens in real-time and can be managed with it.
-
Use
requestAnimationFrame()
for any other case.
Access this course and 1400+ top-rated courses and projects.