Skip to content

perf(storefront): add priority/preload to PDP primary image and first-row collection cards #1983

Description

@filiphsps

What to build

The likely LCP element on PDP and collection pages doesn't have priority, so Next emits no <link rel="preload"> for it. Browsers find the image only after parsing the surrounding markup.

  • product-gallery.tsx:80-89 — primary gallery image uses loading="eager" but omits priority={true}. On a product page this is the LCP element.
  • products-content.tsx:63-65CollectionProductCard is rendered without any priority for the first row. The first row is above the fold on most viewports.

Add:

  • priority={true} on <Image> in product-gallery.tsx for the primary image (the one matching initialImage).
  • Pass a priority prop down CollectionProductCardProductCard<Image> for the first N cards (e.g. first row for the default grid-cols-[repeat(auto-fill,minmax(11rem,1fr))] — pick a count that covers above the fold at the smallest desktop breakpoint).

Acceptance criteria

  • PDP <head> includes <link rel="preload" as="image" href="<primary product image url>">
  • Collection page <head> preloads the first row of card images
  • LCP on a representative PDP and collection page improves measurably (Lighthouse / WebPageTest before/after)
  • No priority regressions — only the actually-above-the-fold images get the boost

Blocked by

None — can start immediately.

References

  • apps/storefront/src/components/products/product-gallery.tsx:80
  • apps/storefront/src/app/[domain]/[locale]/products/products-content.tsx:63
  • apps/storefront/src/components/product-card/product-card.tsx

Metadata

Metadata

Assignees

No one assigned

    Labels

    OptimizationPerformance or bundle optimizations.ready-for-agentFully specified, ready for an AFK agent

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions