If you’ve migrated a Shopify store to Hydrogen (Remix) recently, you might have noticed a counterintuitive trend: your Lighthouse score or Core Web Vitals (specifically LCP - Largest Contentful Paint) isn’t automatically 100/100 just because it’s headless.
In fact, LCP delays in Hydrogen often come down to three specific execution details:
- Unconstrained Image Srcsets from Storefront API: When fetching product hero images via the Storefront API (
image { url width height }), relying on default unoptimized URL parameters often downloads oversized 2000px+ PNG/JPEGs on mobile devices. - Missing
fetchpriority="high"on Hero Elements: Remix server-renders your HTML, but if the main hero banner image doesn’t explicitly tell the browser to prioritize it over secondary assets or scripts, the browser queues it behind hydration bundles. - Sub-request Waterfalls: Fetching your hero banner data inside a nested Remix loader or chaining collection API calls after layout fetches delays the initial HTML response.
Quick Code Fix for LCP Image Tags in Hydrogen:
import { Image } from '@shopify/hydrogen';
export function HeroBanner({ data }) {
if (!data?.image) return null;
return (
<div className="relative w-full h-[500px]">
<Image
data={data.image}
sizes="(min-width: 1024px) 100vw, 100vw"
loading="eager"
fetchpriority="high"
widths={[350, 640, 750, 1080, 1400, 1920]}
className="w-full h-full object-cover"
/>
</div>
);
}
Key Takeaway: Make sure your loader fetches hero data at the top level of the route rather than relying on client-side fetchers, and explicitly pass loading="eager" and fetchpriority="high" to the Hydrogen Image component.