Repository navigation
Description
What happens
On a long page, adding one element anywhere inside a reading column restyles every element under the column. A widget that adds an element when the pointer rests on something, such as a hover card, pays this each time. On a page with a few thousand elements that is 20 to 30 ms before the card can draw.
Reproduction
A page with one part holding an article.layout-column, and inside it a div of 100 paragraphs of 24 <span> words each, about 2,500 elements in all:
<main>
<header><h1>Long page</h1></header>
<lf-parts id="parts">
<lf-part id="one" label="One"><article class="layout-column">
<div id="block"><p><span>word</span> <span>word</span> …</p> …</div>
</article></lf-part>
<lf-part id="two" label="Two"><p>Another part.</p></lf-part>
</lf-parts>
</main>In the browser, append one empty absolutely positioned div to #block and force layout with document.body.offsetHeight. On Chromium 156, in an exported page:
| Median time | Elements restyled | |
|---|---|---|
| As the page is | 20.6 ms | 2,511 |
With #block > * { --lf-shell-width: initial; --lf-free-start: initial; --lf-free-end: initial; } |
1.7 ms |
The devtools trace shows the time in one style recalculation, not in layout. The same page with the block placed directly in <main> doesn't match the column rule below, and takes 1 ms.
Cause, as far as I narrowed it
Neutralizing one rule removes the cost: the .layout-column rule for main and for a part's column, which sets
--lf-shell-width: 100cqi;
--lf-free-start: max(0px, (var(--lf-shell-width) - 100%) / 2 - var(--col-pad));
--lf-free-end: var(--lf-free-start);All three are registered with @property … inherits: true, so every element under the column inherits them, and --lf-free-start stays an unresolved percentage expression all the way down. The cost also needs --col-pad to be defined, since --lf-free-start is otherwise invalid. A plain HTML page with these rules, registrations and a size container did not reproduce it, so some other condition on a Leaf page is involved that I didn't isolate.
Expected
Inserting an element costs about what it costs on a page without the column rule, a millisecond or two. The free-space lengths seem to be read only by the column's own children, such as a wide block sizing itself, so descendants further down may not need to inherit them.
Seen on leaf 82d5001, installed 2026-11-05T23:42:10-08:00.
This was written by Claude Code on behalf of max-sixty
Activity
leaf-agent commentedon Nov 6, 2026
Reproduced on the issue's page. Appending one div took a median 28.9 ms, against 2.3 ms with the room lengths reset below the column. #5609 makes that reset part of the layout: only a block standing directly in a column or flow reads
--lf-free-start/--lf-free-end, so every box whose parent is not a column or flow now sets them to zero. That rule replaces the narrower one that did this only for flows. The breakout and room tests pass locally on Chromium, Firefox and WebKit. The PR's CI and review are still pending. There's no regression test because the guarantee is a timing.