Performance: Animation duration and delay
MEDIUM IMPACT
Animation duration and delay affect how long animations run and when they start, impacting user perception and browser rendering workload.
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } } .element { animation-name: fadeIn; animation-duration: 0.5s; animation-delay: 0s; animation-fill-mode: forwards; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } } .element { animation-name: fadeIn; animation-duration: 5s; animation-delay: 3s; animation-fill-mode: forwards; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Long duration with delay | Minimal | 0 during delay, 1+ during animation frames | High due to continuous repaint | [X] Bad |
| Short duration without delay | Minimal | 0 during delay, fewer during animation frames | Low due to quick repaint | [OK] Good |