Skip to content

PDP: split image priority from loading=eager; account for color slot#249

Merged
laugharn merged 1 commit intopdp-aspect-ratio-and-oos-slideshowfrom
pdp-image-priority
May 5, 2026
Merged

PDP: split image priority from loading=eager; account for color slot#249
laugharn merged 1 commit intopdp-aspect-ratio-and-oos-slideshowfrom
pdp-image-priority

Conversation

@laugharn
Copy link
Copy Markdown
Contributor

@laugharn laugharn commented May 4, 2026

Stacks on #248. Targets pdp-aspect-ratio-and-oos-slideshow so the diff stays scoped to image-loading changes; GitHub will auto-retarget to main once #248 merges.

Summary

Two priority bugs in ProductMedia:

  1. Mobile carousel under-prioritized in color-partitioned mode. The shared-items map used priority={!children && idx === 0}. Whenever a mobileSlot was passed, children was always truthy, so no shared item was marked priority — even if the resolved color images turned out to be empty. The mobile LCP candidate was lazy-loaded.
  2. Desktop grid double-prioritized. GridItem used priority={idx < 2} independently for color images and shared items, so in color-partitioned mode four <link rel=preload> ended up competing for a single PDP.

Fix separates priority (the single LCP candidate; fetchPriority="high" + preload) from loading="eager" (above-the-fold but not LCP; loads now without fighting the LCP for bandwidth), and computes both centrally in ProductMedia based on a hasColorSlot flag.

Rules:

  • Color slot presentcolorImage[0] priority, colorImage[1] eager, shared[0] eager (covers 0- or 1-color-image cases).
  • No color slotshared[0] priority, shared[1] eager.

MediaImage now takes an explicit eager prop so loading semantics aren't conflated with priority. MediaVideo's preview image keeps the combined priority||eager signal — small cost, and the preview is what drives perceived load.

Includes a template-rollout-log entry.

Test plan

  • pnpm --filter template lint and tsc --noEmit clean
  • PDP without color partitioning: first image is the only fetchpriority=high request with a <link rel=preload> in <head>, second is loading=eager (no preload), rest lazy
  • PDP with color partitioning: first color image is the only priority/preloaded request; second color image and first shared image are eager; rest lazy
  • Color-partitioned product where the selected color resolves to no color images: first shared image still loads quickly (eager)
  • No regression in initial paint speed on PDPs with videos as the first media item

🤖 Generated with Claude Code

Two priority bugs in ProductMedia:

1. Mobile carousel under-prioritized in color-partitioned mode. The
   shared-items map used priority={!children && idx === 0}. Whenever
   a mobileSlot was passed (the resolved-color-images Suspense node),
   children was always truthy, so no shared item was marked priority
   even if the resolved color images turned out to be empty. The
   mobile LCP candidate was lazy-loaded.

2. Desktop grid double-prioritized. GridItem used priority={idx < 2}
   independently for color images and shared items. With color
   partitioning on, the first two color images were priority and the
   first two shared items at visual positions 3/4 also got priority,
   so four <link rel=preload> ended up competing for a single PDP.

Fix:

- Separate priority (the single LCP candidate; fetchPriority high +
  preload) from loading=eager (above-the-fold but not LCP; loads now
  without fighting the LCP for bandwidth).
- Compute hasColorSlot once in ProductMedia and pass it down.
- Color slot present: colorImage[0] is priority, colorImage[1] is
  eager, shared[0] is eager (covers the case where color resolves to
  0 or 1 images).
- No color slot: shared[0] is priority, shared[1] is eager.

MediaImage now takes an explicit eager prop so loading semantics
aren't conflated with priority. MediaVideo's preview image keeps the
combined priority||eager signal — small cost, and the preview is
what affects perceived load.

Adds a template-rollout-log entry.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
shop-docs Ready Ready Preview, Comment May 4, 2026 9:17pm
shop-template Ready Ready Preview, Comment, Open in v0 May 4, 2026 9:17pm

@laugharn laugharn merged commit db41204 into pdp-aspect-ratio-and-oos-slideshow May 5, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant