Repository navigation
perf(site): stop whole-page restyles on the home page, set sections up as they near the view - #105
Merged
Merged
Conversation
`:root:has([data-va-hero]) .site-footer` made the root element a `:has()` anchor. Chromium then scheduled its merged `:has()` invalidation set on <html> for every node inserted or removed anywhere on the page, and Starlight's list-spacing rule makes that set "all descendants". Each loader update therefore restyled 2,000 to 3,800 elements, and every forced style read paid for it. The footer now knows it is on the home page (the same check Hero.astro uses) and drops its top margin there, so the page looks the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every home section registered all nine elements and wired up its demo at load, so the whole page upgraded in the first seconds. Now: - the first screen registers only its own five elements and starts at once, as before; - each section further down registers what it uses and sets up once it is within a window's height of the view, in a task of its own; - shapeRows measures every cell before its first write, and the activity feed reads every position before it restarts the glides with a single reflow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Profiling showed that the long tasks on
/were mostly style recalculation, not JavaScript. One CSS rule made every DOM change restyle the whole page.Why it was so expensive:
:root:has(…) .site-footermakes<html>a non-subject:has()anchor. On every node inserted or removed anywhere, Chromium schedules its merged:has()invalidation set on that anchor. Starlight's list-spacing rule (.sl-markdown-content :is(ol,ul):has(> li > …) > li > …) makes that set "all descendants". So each loader update restyled 2,000–3,800 elements, and everygetBoundingClientRect/getComputedStylethe runtime makes paid for it. Removing either rule fixes it. Starlight's rule is left alone; ours goes.Then, as the brief asked, the sections stop setting up all at once:
Layout reads are batched too:
shapeRows(lib.ts): measures every cell before it writes. Used by the hero and invoices tables.Evidence
Main-thread time:
/at 412 × 823, 4× CPU, 150 ms RTT at 1.6 Mbps, local build. Median of 7 runs. TBT here is the sum of (long task − 50 ms) from FCP to 10 s, which includes the first screen's loop.The same profiler measures production (
https://dotquilt.dev/, 3 runs) at 1,213 ms, in line with the audit's 1,280 ms. Production is higher than the local build because of real serving; the before/after ratio is the comparison that matters.Where the time went before:
eligible()→getBoundingClientRect.Tests: three new ones in
tests/site/home.spec.ts.bunx playwright test --project=site-chromium→ 85 passed, including the first screen, hold-to-load, invoices, activity, family, handoff, playground and details tests.bun run lint,bun run check,bun run testpass.Same look, same behaviour. These checks compared the before and after builds and were not committed:
complete; family 5complete+ 1immediate; closing 2complete.Merge Danger
Door: two-way
A revert restores the old scripts and rule. Nothing is stored or published.
Blast Radius: home page
/gets thehomeclass, and the test checks both cases.Footer.astroandtests/site/home.spec.ts, but in different places, so it should rebase cleanly.🤖 Generated with Claude Code