Web Performance Engineering

Optimizing Core Web Vitals (LCP, INP, CLS) in Next.js

Fast initial HTML delivery, zero layout shift, and responsive interactions directly improve both organic search eligibility and user conversion rates.

1. Server-Render Hero Content for Fast LCP

Keep public page shells, primary <h1> headings, metadata, and JSON-LD in Server Components. When fetching live telemetry client-side, scope loading indicators to data widgets rather than hiding the entire page behind a full-screen spinner.

2. Font Loading, Image Formats & Zero CLS

  • Self-host Google Fonts via next/font/google with display: "swap" to prevent invisible text flashes.
  • Enable AVIF and WebP formats in next.config.js and reserve explicit dimensions for media containers to keep CLS near 0.
  • Defer non-critical third-party scripts with afterInteractive so main-thread INP remains fast.

Frequently Asked Questions

Why do client-rendered loading spinners hurt Largest Contentful Paint (LCP) and SEO?

When a page replaces its entire hero section with a loading spinner until client-side API calls resolve, initial HTML has little semantic content for crawlers and the browser cannot paint the primary hero element until JavaScript downloads and fetches data.

How should analytics scripts be loaded in Next.js without hurting INP?

Load GA4, Google Tag Manager, and session tools using next/script with strategy="afterInteractive" so they never block main-thread hydration or first input responsiveness.

Measure your domain's Core Web Vitals and technical SEO health now.
Run Free Diagnostic →