Repository navigation
fix(image): the LCP hero is lazy-loaded and preload-invisible - #144
Conversation
A CSS `background-image` is invisible to the browser's preload scanner and cannot carry `fetchPriority`, so the hero request only starts once the render tree is built. An `img` element can, and React emits a hoisted `<link rel="preload" as="image">` for a non-lazy one, so the preload this repo lacks comes for free. `priority` defaults to false, so every splash is lazy until its caller opts in. The next commit gives the lead splash that opt-in. Co-authored-by: sydevs-bot <[email protected]> Claude-Session: https://claude.ai/code/session_01Kc1j19vPbg9MtAwdbWJ2P5
Only the page's first root-level block is above the fold, so only it should preempt the network. `getLeadSplash` decides the same thing from `page.content`, but nothing threads its answer into a converter, so the position comes from the converter args: root-level children are dispatched with `childIndex: i` and `parent: data.root`. A splash anywhere else keeps `loading="lazy"`, which a CSS background never had either way. Co-authored-by: sydevs-bot <[email protected]> Claude-Session: https://claude.ai/code/session_01Kc1j19vPbg9MtAwdbWJ2P5
Trim the three new comments to the why each carries, and drop the story's duplicate non-priority panel — five other sections already render a default splash, and the two differed only in markup. Co-authored-by: sydevs-bot <[email protected]> Claude-Session: https://claude.ai/code/session_01Kc1j19vPbg9MtAwdbWJ2P5
…ispatch The blockConverters specs hand-build `childIndex` and `parent`, so a library change that stopped supplying either would revert the hero to lazy with the suite still green. This renders RichText instead, which drives the library's own dispatch. Also unclip the new story section, which was the only clipped full-bleed splash in the file. Co-authored-by: sydevs-bot <[email protected]> Claude-Session: https://claude.ai/code/session_01Kc1j19vPbg9MtAwdbWJ2P5
The `Image` atom's `opacity-0`-until-hydration gate silently disqualifies any hero routed through it, so the next contributor to "simplify" a hand-rolled hero img back into the atom would regress LCP with no test failing. Co-authored-by: sydevs-bot <[email protected]> Claude-Session: https://claude.ai/code/session_01Kc1j19vPbg9MtAwdbWJ2P5
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
wemeditate-web | f1c0875 | Commit Preview URL Branch Preview URL |
Oct 01 2026, 09:05 PM |
|
🤖 no session running recent dispatchesWritten by the sydevs dispatcher. Sessions never edit this comment. |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
Proportionate to #142: ~25 source lines, the rest tests and a story. Earning React's hoisted preload beats a hand-written <link>. Splash has one consumer, so no other hero silently drops to loading="lazy". Two things reach past the ticket, neither blocking: a doc rule #145 already claims, and a second definition of "the lead block".
Findings
- should-fix —
DESIGN_SYSTEM.md:284states a permanent rule that #145 contradicts and that fights line 283. - consider —
blockConverters.tsx:311restatesgetLeadSplash's predicate in a second file. - consider —
Splash.stories.tsx:98adds a panel identical to its five neighbours.
What was checked
Read whole: Splash.tsx, the splash converter, its story, content-blocks.ts:260-310, RichText.tsx:243-275 — withDebugOverlay forwards args whole, so debug keeps childIndex. Grepped every <Splash and getLeadSplash site: one and four. No contract surface touched. React's <picture> rule comes from #145: no node_modules here to re-check it.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
The bullet stated "never the <Image> atom" as a permanent rule. #145 makes <Image priority> the right answer above the fold, and the WebP bullet above it recommends <picture>, which suppresses the hoisted preload. A contributor reading both got no answer. Keep the durable half — eager plus high fetchPriority, no CSS background — and scope the atom's exclusion to today. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TEabkgbbusRKFZzDmddi4D
Every other StorySection in this file passes inContext, so the new panel rendered without the divider its neighbours get. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TEabkgbbusRKFZzDmddi4D
The converter reads childIndex/parent, getLeadSplash reads content.root.children[0]. They agree today and nothing kept them agreeing, so drift would point the overlaid header at a lazy image while the preload stayed on the old block. Assert both answers on the same content tree. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TEabkgbbusRKFZzDmddi4D
Deploying wemeditate-design with
|
| Latest commit: |
f1c0875
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://461e025e.wm-design.pages.dev |
| Branch Preview URL: | https://claude-fix-142-lcp-hero-eage.wm-design.pages.dev |
|
Addressed the adversarial review. Pushed 719064e. Lean gate green — lint 0 errors,
🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
One conflict, in the DESIGN_SYSTEM.md Performance list. Both sides added an above-the-fold image rule to the same bullet position. main (#148) fixed the Image atom's opacity-0-until-hydration gate and gave it a priority prop, so this branch's bullet cited a blocker that no longer exists. The second blocker still holds: the atom's container owns the layout and className reaches the image, and #145 deferred a fill mode, so a hero that must fill its parent still hand-rolls an img. The resolved bullet keeps that reason, main's `<Image priority sizes>` guidance and its one-or-two-per- page cap, and the never-a-CSS-background and `<picture>`-suppresses-the- preload rules. main's separate first-render-must-be-visible bullet is kept whole. Splash.tsx carried the same stale opacity-0 reason in a comment. git merged it clean because main never touched the file, so it is corrected here to the container-layout reason it now rests on. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01DzGDzXPkGrSomd1FAi7Ern
|
Merged The resolved bullet keeps both. From this branch: never a CSS One half of this branch's bullet was dropped, because
🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
|
No code change — CI is green on GitHub created two CI runs for the same Run 215 finished at 21:06:07. Smoke (web), Smoke (ladle) and Lint, Typecheck & Unit all passed on this sha.
🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
|
CI is still red after 3 fix attempts (failing: Smoke (web), Smoke (ladle), Lint, Typecheck & Unit). I have stopped retrying. A comment or a push from you starts me again. 🤖 sydevs dispatcher |
Summary
splashhero paints as an<img loading="eager" fetchPriority="high">instead of an inline CSSbackground-image, so the preload scanner can see it.<link rel="preload" as="image">for that element, so the preload the repo lacked needs no hand-written<link>.splashthat is not the page's first block staysloading="lazy", and no other image changes.Preview
Preview pending — Cloudflare names it after a branch slug, so the alias only exists once the build posts. When it does, open:
Organisms → Splash → "LCP Priority"— the new section's markup carriesloading="eager",fetchPriority="high"and the hoisted preload link.Test results
.claude/skills/pr-prep/check.sh— lint (0 errors),tsc --noEmit,vitest runblockConverters.test.tsx, 2 inRichText.test.tsxThe
RichText.test.tsxspecs render through the library's own converter dispatch rather than a hand-built argument object, so if@payloadcms/richtext-lexicalever stopped supplyingchildIndex/parentthe hero would not silently revert to lazy.Manual verification
Against the web preview, on a page that leads with a splash:
curl -s <url> | grep -ioc 'fetchpriority="high"'— at least 1. Grep case-insensitively: React serialises the attribute asfetchPriority.curl -s <url> | grep -c 'rel="preload"'— at least 1.curl -s <url> | grep -c 'background-image'— 0.Notes for reviewer
The ticket's open question is still open, and criterion 4 answers it one way. A
splashbelow the lead block is nowloading="lazy". A CSS background was neither lazy nor eager, so either choice is a change. If a page ever puts a short paragraph above a full-screen splash, that hero is largely in the viewport andlazywould start its fetch later than today. Say the word and it becomesloading={undefined}for the second root block.ultrawide-2048is not what ships.Splashasks for it, butgetImageURLreturns its input for every URL SahajCloud actually serves (/public, per #141), so the hero gets one fixed variant before and after this PR. The<img>therefore carries nosrcSet/sizes— that is #141's work, not this PR's, and this PR does not make it worse.prioritytrustsgetLeadSplash's assumption.PageTemplatestill renders afeaturedVideo/author byline aboveRichText, so a page with both a lead splash and a featured video would put chrome above the "hero". That assumption is already shipped —getLeadSplashdrivesLayoutChrome's overlaid header and flush-to-top spacing the same way — so makingprioritydisagree with it would be worse. I could not confirm whether such a page exists: SahajCloud returns 403 to this session's key.Adversarial review, and what it changed
Three findings, all answered on the thread.
DESIGN_SYSTEM.md:284— adopted (77cd64d). The bullet said "never the<Image>atom" as a permanent rule, which fix(image): the Image atom hides every image until hydration #145 contradicts and which fights the<picture>bullet above it. It now states only the durable half, scopes the atom's exclusion to today behind fix(image): the Image atom hides every image until hydration #145, and names the<picture>suppression inline.blockConverters.tsx:311— not unified, pinned instead (719064e). The converter map is a static module-level object, so threading a lead index down fromRichTextmeans making it a factory and rewiring every converter. The named risk was drift, so a spec now asserts the converter'spriorityandgetLeadSplashover one content tree.Splash.stories.tsx:98— panel kept, nit adopted (fb60309). fix(image): the LCP hero is lazy-loaded and preload-invisible #142 asks for the priority story. The section was the only one in the file withoutinContext, so it lost its divider.Dismissed review findings, and why
Four of eleven findings across
/simplifyand/code-review highwere dismissed.Imageatom and addprioritythere instead." Both of the ticket's blockers hold.Image.tsx:306keeps the image atopacity-0until hydration firesonLoad, which excludes it from LCP candidacy; and its container isrelative ${aspectRatioStyles} ...whileclassNamereaches the image, not the container. The suggested<Image priority className="absolute inset-0 w-full h-full">would absolutely position the<img>against thatrelativewrapper — a zero-height box in Splash's flex parent — so the hero would not fill the viewport. Making it work needs the atom's container layout changed too, which is the wider defect the ticket deferred.Avatar.tsx:113is the existing precedent for a hand-rolled<img>. Filed separately as fix(image): the Image atom hides every image until hydration #145.loadingoff for the second root block too." Acceptance criterion 4 requiresloading="lazy"for a non-lead splash. Surfaced above instead of overridden.alt=""andaria-hidden="true"are redundant on one<img>." True, and both are what the ticket prescribes; the<div>being replaced carriedaria-hiddentoo. Kept.Accepted: the three new comments were trimmed to the why each carries, the story's duplicate non-priority panel was dropped (five other sections already render a default splash) and then unclipped to match its neighbours, and the contract-level test was added.
Why an element and not a hand-written <link>
Verified against the installed
[email protected]rather than assumed.react-dom-server'scase "img"emits a hoisted<link rel="preload" as="image">for any<img>with asrcunless it isloading="lazy",fetchPriority="low", adata:URI, or inside<picture>/<noscript>. It can also route that preload into aLink:response header instead of the HTML, but only whenonHeadersis configured — nothing in this repo or invike/vike-reactsets it, so the<link>lands in the document.renderToStaticMarkupreproduces it, which is what makes criterion 3 assertable in CI rather than only by curl.Fixture pre-mortem: the specs assume an upload ref is a populated object with a non-empty string
url, which is allpopulatedImage(lib/content-blocks.ts:213) andisPopulated(lib/payload-relationships.ts:9) require — both read directly. They also assume root-level children arrive withchildIndex: iandparent: data.root; that is the real dispatch in@payloadcms/richtext-lexical'sconvertLexicalNodesToJSX, andJSXConverterArgsdeclares both, so theRichText.test.tsxspecs exercise it rather than trusting it.Closes #142
🤖 Generated with Claude Code
https://claude.ai/code/session_01Kc1j19vPbg9MtAwdbWJ2P5