Sixty lanterns over the field: swing them by left, transform or width, each frame’s time measured for real, will-change read back from the elements and their…
Why it matters
A smooth animation means every frame done in a few milliseconds. left, top and width force a new layout every frame; transform and opacity do not. will-change put everywhere wastes GPU memory and can move fixed elements.
The key idea
Pick the cheap property first, will-change second
Common mistakes
The page lags when many elements get will-change at once Every element with will-change can become a layer of its own, its picture kept in GPU memory. On weak devices that slows things down, even crashes the tab. Set it just before the animation, take it off after.
An animation on top/left still stutters Those properties force a new layout every frame. Use transform: translate(), which only moves the picture.
will-change is set and it is still janky will-change does not make an expensive property cheap. If width is animated, change the property (transform: scaleX()), do not add will-change.
Try it in this playground
Swing with left, then with transform Their layout cost per frame is far apart.
Swing with will-change on every lantern 60 elements with will-change, and their estimated memory, while the layout cost stays the same.
Animate width with will-change: width Its layout stays expensive.
Set will-change just for a moment After the swing, none is left.