Home / Learn / What are the 15 most common web animation mistakes?

What are the 15 most common web animation mistakes?

Most motion problems repeat: slowness, annoying motion, broken Arabic, or motion nobody asked for. The 15 mistakes sit in 5 groups, each with a source or note, plus a baseline code that avoids most of them.

Steps

  1. Performance: (1) Animating layout properties such as width and top instead of transform and opacity (web.dev). (2) Putting will-change on everything: MDN says use it as a last resort for an existing performance problem, not to anticipate problems. (3) Using setInterval/setTimeout for motion instead of requestAnimationFrame (MDN, CSS and JavaScript animation performance).
  2. Access: (4) Ignoring prefers-reduced-motion (MDN). (5) Flashing more than three times per second (WCAG 2.3.1). (6) Automatic motion longer than five seconds with no way to stop it (WCAG 2.2.2).
  3. Clarity: (7) Text contrast below 4.5:1 (or 3:1 for large text) (WCAG 1.4.3). (8) Long durations: NN/g says 500 ms starts to feel like a drag and most fall between 100 and 500. (9) Moving numbers without tabular-nums, so they jitter (MDN).
  4. Arabic and RTL: (10) Splitting Arabic words into letters or adding letter-spacing, which breaks the joins (MDN). (11) Using left/right instead of logical properties, so motion flips wrongly in RTL (MDN). (12) Forgetting lang and dir on the page (W3C).
  5. Build: (13) Redrawing everything on Canvas every frame instead of pre-rendering repeated shapes on an offscreen canvas (MDN). (14) Hard-coding durations and colors everywhere instead of CSS variables (MDN, custom properties). (15) Using GIF or MP4 for simple vector motion, when LottieFiles says Lottie files are smaller than both (the vendor's claim).

Sources

The code below fixes most of the first six mistakes in a few lines: transform and opacity only, logical properties, steady-width digits, no letter-spacing on Arabic, variables for timing, and a calm mode.

The code

CSS

/* 1. animate transform and opacity only */
.card{transition:transform .25s ease-out,opacity .25s ease-out}

/* 2. logical properties instead of left/right */
.badge{margin-inline-start:.5rem;padding-inline:.75rem}

/* 3. steady digits so numbers do not jitter */
.stat{font-variant-numeric:tabular-nums}

/* 4. never letter-space Arabic */
:lang(ar){letter-spacing:0}

/* 5. one place for timings */
:root{--t-fast:150ms;--t-base:250ms}

/* 6. calm mode */
@media (prefers-reduced-motion: reduce){
  *,*::before,*::after{animation:none !important;transition:none !important;scroll-behavior:auto !important}
}

The final "calm mode" pattern (turning off animation and transition) is a common pattern, not a word-for-word recommendation from one source. Test it on your site.

can't find the motion you need? Request it here