CSS animations first
There are a few reasons why CSS animations are often preferred over JavaScript animations:
Performance
CSS animations are typically hardware-accelerated, which means they can be smoother and more performant compared to JavaScript animations. This is especially true for simple animations like transitions and fades.
Ease of use
CSS animations can be easily applied to elements using CSS classes or pseudo-classes, without the need for writing JavaScript code. This makes it simpler and faster to implement and maintain animations.