CSS3 & Modern Layouts (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)
What is `will-change` in CSS and why should you use it sparingly?
senior LevelSystem Design
In Simple Words:
will-change: transform hints to the browser ahead of time that an element is about to animate, instructing it to promote the element to its own dedicated GPU Compositing Layer.
- Why use sparingly:
- Each composited layer consumes dedicated VRAM (video memory).
- Applying
will-changeto 100 list items consumes hundreds of megabytes of GPU memory, causing mobile devices to crash or drop frames! - Best practice: Add
will-changeon:hoverright before animation, and remove it once animation completes.