GreenIT | V2 | V3 | V4 |
---|---|---|---|
810 | 48 | 39 |
Life cycle | Tiers | Responsible |
---|---|---|
2. Design | User/Device | UX/UI Designer |
Priority | Implementation difficulty | Ecological impact |
---|---|---|
4 | 3 | 5 |
Saved resources |
---|
Processor / RAM |
JavaScript/CSS animations can request a lot of CPU cycles and memory.
They all trigger resource-intensive (re)paint/(re)flow type actions. Animations must be avoided as much as possible, and only used when required.
If some animations are essential, stick to the CSS opacity
and transform
properties, and to the translate
, rotate
, scale
related functions of transform
. These two properties are automatically browser optimized, and the animations can be managed by the graphics processing unit (GPU). The following website www.csstriggers.com features a list of DOM actions than con be triggered by an animation.
Browsers can be informed that an animation is going to take place with a will-change
statement in order to reduce animation-related resource consumption.
To know more :
https://web.dev/animations-guide/
.box {
will-change: transform, opacity;
}
You can also let the users choose whether or not to play animations via the browser preferences and the through prefers-reduced-motion
media queries. Animations will only be played if no preferences have been set by the user.
@media (prefers-reduced-motion: no-preference ) {
.animation {
animation: fadeIn 4s ease;
}
}
The number of ... | is equal to or less than |
---|---|
JS / CSS animations per page | 2 |