Will Change Sparingly
Apply CSS will-change only to specific elements that will animate imminently; never apply it to body, large containers, or elements that won't animate; remove or reset it after animation completes.
$ prime install @community/rule-will-change-sparingly Projection
Always in _index.xml · the agent never has to ask for this.
WillChangeSparingly [rule] v1.0.0
Apply CSS will-change only to specific elements that will animate imminently; never apply it to body, large containers, or elements that won't animate; remove or reset it after animation completes.
Loaded when retrieval picks the atom as adjacent / supporting.
WillChangeSparingly [rule] v1.0.0
Apply CSS will-change only to specific elements that will animate imminently; never apply it to body, large containers, or elements that won't animate; remove or reset it after animation completes.
Severity
warning
Applies When
adding CSS transitions or JS-driven animations to any element
Verify By
Audit for body-level, wildcard, or container-wide will-change declarations. Confirm will-change is scoped to the animating element and removed (or set to auto) after the animation ends.
Code
/* BAD — promotes entire page to GPU layer, excessive VRAM use */
body { will-change: transform; }
* { will-change: opacity; }
/* GOOD — apply only to the element that will animate, just before animation */
.modal { will-change: transform, opacity; }
/* After animation: remove it */
.modal.is-done { will-change: auto; }
/* GOOD with JS — apply before animation, clean up after */
element.style.willChange = 'transform';
element.addEventListener('transitionend', () => {
element.style.willChange = 'auto';
}, { once: true });
/* For hover: use :hover to scope to the interaction window only */
.card:hover { will-change: transform; }
/* This is acceptable — short-lived, scoped to hover state */
Loaded when retrieval picks the atom as a focal / direct hit.
WillChangeSparingly [rule] v1.0.0
Apply CSS will-change only to specific elements that will animate imminently; never apply it to body, large containers, or elements that won't animate; remove or reset it after animation completes.
Severity
warning
Applies When
adding CSS transitions or JS-driven animations to any element
Verify By
Audit for body-level, wildcard, or container-wide will-change declarations. Confirm will-change is scoped to the animating element and removed (or set to auto) after the animation ends.
Code
/* BAD — promotes entire page to GPU layer, excessive VRAM use */
body { will-change: transform; }
* { will-change: opacity; }
/* GOOD — apply only to the element that will animate, just before animation */
.modal { will-change: transform, opacity; }
/* After animation: remove it */
.modal.is-done { will-change: auto; }
/* GOOD with JS — apply before animation, clean up after */
element.style.willChange = 'transform';
element.addEventListener('transitionend', () => {
element.style.willChange = 'auto';
}, { once: true });
/* For hover: use :hover to scope to the interaction window only */
.card:hover { will-change: transform; }
/* This is acceptable — short-lived, scoped to hover state */
Rationale
will-change promotes an element to a GPU compositing layer, allocating a dedicated texture region in VRAM. Blanket application (body, *, large containers) pre-allocates GPU memory for elements that don't need it, causing more performance harm than it prevents — especially on mobile devices with limited GPU memory.
Severity
warning
Applies When
adding CSS transitions or JS-driven animations to any element
Verify By
Audit for body-level, wildcard, or container-wide will-change declarations. Confirm will-change is scoped to the animating element and removed (or set to auto) after the animation ends.
Code
/* BAD — promotes entire page to GPU layer, excessive VRAM use */
body { will-change: transform; }
* { will-change: opacity; }
/* GOOD — apply only to the element that will animate, just before animation */
.modal { will-change: transform, opacity; }
/* After animation: remove it */
.modal.is-done { will-change: auto; }
/* GOOD with JS — apply before animation, clean up after */
element.style.willChange = 'transform';
element.addEventListener('transitionend', () => {
element.style.willChange = 'auto';
}, { once: true });
/* For hover: use :hover to scope to the interaction window only */
.card:hover { will-change: transform; }
/* This is acceptable — short-lived, scoped to hover state */
Source
prime-system/examples/frontend-design/primes/compiled/@community/rule-will-change-sparingly/atom.yaml