Avoid expensive JavaScript/CSS animations


JavaScript/CSS animations can be very expensive in terms of CPU power and RAM usage. They all trigger actions such as (re)paint/(re)flow that consume a lot of resources. Thus avoid using animations as much as possible, and only do so when absolutely necessary.
If you must include an animation, only employ the opacity and transform CSS3 properties as well as the related functions: translate, rotate, scale and transform. These two properties are automatically optimized by the browser, and the animation can be handled by the GPU. lists the DOM-related actions triggered by an animation.
You can help the browser minimize the resources consumed by using will-change to warn it that an amination will take place.

The will-change property warns the browser that an animation, which it is capable of optimizing, will be triggered. Used intelligently, this approach will consume less resources.

.box {
  will-change: transform, opacity;

To learn more:

This best practice should only be applied if it is coherent with your project's specifications.
Under CC-By-NX-SA license