Why Does Everything Lag?
When you run animation, browser goes through 3 stages:
- Layout (Reflow): Recalculating sizes and coordinates of ALL elements on page. (Slowest stage).
- Paint: Drawing pixels.
- Composite: Gluing already drawn layers (Fastest stage).
Golden Rule:
Animate only properties that cause only Composite:
transform(scale, rotate, translate)opacity
Bad Properties for Animation:
width,height,top,left,margin. They cause Layout.
Caution
If you animate width of one block, browser has to recheck position of ALL other blocks on page. If there are 1000 — interface will " lag " .