Performance: Custom keyframe animations
MEDIUM IMPACT
Custom keyframe animations affect the browser's paint and composite stages, impacting visual smoothness and interaction responsiveness.
@keyframes smoothTransform {
0% { transform: translateX(0); }
100% { transform: translateX(100px); }
}
.animate-transform {
animation: smoothTransform 2s infinite;
will-change: transform;
}@keyframes slowLayoutShift {
0% { width: 100px; }
100% { width: 200px; }
}
.animate-width {
animation: slowLayoutShift 2s infinite;
}| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Animating width | None | 1 per frame | High (layout + paint) | [X] Bad |
| Animating transform | None | 0 | Low (composite only) | [OK] Good |