Hover Jank: white-space in :hover Forces a Reflow Feedback Loop
Hover animations that touch layout properties like white-space, word-break, font-size, or line-height cause a full reflow every frame, and in grid-aligned lists that reflow spans the entire row. Checking Performance for purple Layout blocks and enabling Layout Shift Regions in DevTools makes the culprit immediately visible, so this class of jank is both diagnosable and preventable with standard patterns.
A Vue.js project shows a list of cards, each packed with fields (port, packet count, traffic, etc.), and each field reveals a copy icon on hover. When the mouse sweeps across a row, the copy buttons appear with a noticeable delay, even though scrolling and static rendering stay smooth. The developer first suspected the copy button's opacity/visibility transition, but removing it changed nothing. Commenting out two lines in the :hover rule — white-space: normal and word-break: break-word — eliminated the stutter entirely.
The cause sits in the browser's rendering pipeline. white-space and word-break change how text wraps, which directly determines element width and height, so they force a full Layout pass (reflow) and re-measurement of text. By contrast, opacity and visibility only reach Paint or Composite, which are much cheaper. Worse, hover-induced layout changes alter the element's hit-testing area: the cursor slips out, hover cancels, the layout shifts back, and hover re-triggers — a negative feedback loop called hover flicker. The fix is to never change layout-affecting properties in :hover; instead, use absolutely positioned overlays or tooltips that don't participate in document flow.
The cost of a hover effect isn't about the property's name but its trigger stage in the rendering pipeline; white-space looks harmless yet behaves like width or height.
Grid row alignment amplifies a single field's reflow into a whole-row layout change, turning local jank into visible stutter across the list.
The hover feedback loop is a genuine negative feedback cycle: layout and hit-testing mutually influence each other, so the first fix is to break the dependency by removing layout changes from the hover state.
The author's terse 'give it to AI' option, while humorous, implies that LLMs can propose solutions but the developer still needs to understand the rendering pipeline enough to validate them.
The pit of changing layout properties inside :hover is unforgettable once you've stepped on it; the jank appears out of nowhere. Sticking to visibility and opacity is reliable—just pre-fill the size.
Haha yeah, stepped on it once, left a deep impression, that thing.
Haha, AI, you also get it.