Full-Stack Web & Next.js Architecture

Optimizing Core Web Vitals (INP, LCP, CLS): A Technical Engineering Blueprint for 2026

Field-data-driven engineering blueprint for INP, LCP and CLS: main-thread scheduling, critical path budgets, layout reservation and CI performance gates.

Thushara SanjeewaLead Systems Architect & Media Buying Director8 min read

Core Web Vitals stopped being a marketing metric the moment Interaction to Next Paint (INP) replaced First Input Delay. FID measured whether the browser noticed an input; INP measures whether the interface actually finished the job. That change exposes real architectural debt: oversized hydration payloads, synchronous state cascades, unbatched third-party scripts and layout thrash inside event handlers.

The engineering problem is that lab tools reward the wrong optimisations. A Lighthouse score of 98 on a throttled desktop run coexists comfortably with a 340 ms p75 INP on mid-tier Android devices in real traffic. Field data — Chrome UX Report and your own Real User Monitoring (RUM) — is the only source of truth, and it must be segmented by device class, connection, route template and interaction type before any optimisation work begins.

This blueprint is written for engineering leaders who need vitals to be a controlled system property rather than a quarterly firefight. It covers the diagnostic model per metric, main-thread scheduling techniques, image and font delivery rules, layout reservation discipline, and how to gate regressions in CI. Targets assumed throughout: LCP under 2.5 s, INP under 200 ms, CLS under 0.1, measured at the 75th percentile on mobile.

LCP: Treat the Critical Path as a Budget

LCP is rarely one problem; it is four measurable phases — time to first byte, resource load delay, resource load duration and element render delay. Instrument all four, because the fix differs completely.

  • TTFB dominant: cache at the edge, remove blocking upstream calls from the document response, and stream the shell so bytes flow before data resolves.
  • Load delay dominant: the LCP resource is discovered too late. Emit it in the initial HTML, add fetchpriority="high", and preconnect to its origin. Never lazy-load a hero image.
  • Load duration dominant: wrong format or wrong size. Serve AVIF or WebP, generate a responsive srcset matched to real container widths, and cap hero payloads at roughly 150 KB.
  • Render delay dominant: a blocking script or font, or client-side rendering of above-the-fold content. Inline critical CSS, defer non-essential JavaScript, and render the hero on the server.

Font Strategy

Self-host and subset fonts, declare font-display: swap, and preload only the single face used in the LCP element. Every additional preloaded weight competes with the hero image for early bandwidth.

INP: Scheduling, Not Micro-Optimisation

INP is a scheduling problem. Break each slow interaction into input delay, processing duration and presentation delay, then apply the matching control.

  1. Reduce hydration surface. Ship interactive JavaScript only for genuinely interactive subtrees. Server-render or statically render everything else. Cutting main-thread parse work reduces input delay directly.
  2. Yield to the main thread. Split long tasks with scheduler.yield() where available, falling back to a post-task yield. Any task over 50 ms is a candidate.
  3. Separate urgent from deferred state. Paint the visual acknowledgement of a click immediately; run filtering, sorting and analytics afterwards. In React, useTransition and useDeferredValue express this cleanly.
  4. Avoid layout thrash inside handlers. Batch reads before writes; never interleave getBoundingClientRect() with style mutations in a loop.
  5. Constrain third parties. Load tags after interaction or via a web worker, and enforce a per-vendor main-thread budget. A single tag manager can own the majority of your INP tail.

Presentation Delay

Large DOM subtrees make even cheap updates expensive to paint. Apply content-visibility: auto to long off-screen sections, virtualise lists over roughly 100 rows, and keep animated properties limited to transform and opacity so work stays on the compositor.

CLS: Reserve Space Deterministically

CLS is fully preventable and therefore the cheapest metric to fix permanently.

  • Set explicit width/height or aspect-ratio on every image, video, iframe, chart and ad slot.
  • Reserve fixed containers for banners, cookie notices and A/B-test variants; never insert them above existing content after paint.
  • Match fallback and web font metrics using size-adjust descriptors to eliminate reflow on font swap.
  • Give skeletons the same box dimensions as the loaded component — a skeleton that is shorter than its content is itself a shift.

Benchmarks and Optimisation Leverage

MetricGood (p75)Primary bottleneckHighest-leverage fixTypical measured gain
LCP≤ 2.5 sLate resource discoveryPreload hero + fetchpriority="high"300–900 ms
LCP≤ 2.5 sOrigin TTFBEdge cache + streamed shell200–700 ms
INP≤ 200 msHydration and long tasksReduce client JS, yield in handlers80–250 ms
INP≤ 200 msThird-party scriptsDeferred / worker-based loading50–180 ms
CLS≤ 0.1Unsized media, late bannersAspect-ratio + reserved slots0.05–0.25
TTFB≤ 800 msBlocking upstream callsCache tags, parallel fetches150–500 ms

Instrumentation Blueprint

Collect field metrics with attribution so each regression maps to a component, not a page.

ts
import { onLCP, onINP, onCLS } from "web-vitals/attribution";

type VitalPayload = {
  name: string;
  value: number;
  rating: string;
  target?: string;
  route: string;
  deviceMemory?: number;
  connection?: string;
};

function report(metric: {
  name: string;
  value: number;
  rating: string;
  attribution?: Record<string, unknown>;
}) {
  const nav = navigator as Navigator & {
    deviceMemory?: number;
    connection?: { effectiveType?: string };
  };

  const payload: VitalPayload = {
    name: metric.name,
    value: Math.round(metric.value),
    rating: metric.rating,
    target: String(metric.attribution?.["interactionTarget"] ?? metric.attribution?.["element"] ?? ""),
    route: document.documentElement.dataset["routeTemplate"] ?? location.pathname,
    deviceMemory: nav.deviceMemory,
    connection: nav.connection?.effectiveType,
  };

  navigator.sendBeacon("/api/public/vitals", JSON.stringify(payload));
}

onLCP(report, { reportAllChanges: false });
onINP(report, { durationThreshold: 40 });
onCLS(report);

Store the route template rather than the raw path so dashboards aggregate correctly, and always chart p75 by device class — averages hide the population that fails.

Strategic Action Plan: 90 Days

  1. Days 1–10 — Build the field baseline. Ship RUM with attribution, segment p75 by route template and device class, and publish the three worst routes per metric.
  2. Days 11–30 — Fix the critical path. Server-render above-the-fold content, preload the LCP resource, convert images to AVIF/WebP with correct srcset, and self-host subsetted fonts.
  3. Days 31–55 — Attack INP. Cut hydration scope, introduce yielding in the slowest three handlers, defer non-essential third parties, and virtualise long lists.
  4. Days 56–70 — Eliminate CLS structurally. Enforce dimensions or aspect-ratio on all media via lint rules, reserve slots for banners and experiments, and align font metrics.
  5. Days 71–90 — Gate regressions. Add bundle-size and Lighthouse-CI budgets to pull requests, alert on p75 field regressions above 10%, and review vitals in the same forum as uptime.

Frequently Asked Questions

Why does our Lighthouse score look good while field Core Web Vitals fail?

Lighthouse is a single simulated load on one device and network profile; Core Web Vitals assessment uses the 75th percentile of real visits across all devices. Slow Android hardware, cold caches, variable networks and real interaction patterns are invisible in lab runs. Use Lighthouse for diagnosing causes and field RUM or CrUX data for deciding priorities and declaring success.

What is the fastest way to improve INP on a React application?

Reduce the amount of JavaScript that hydrates, then make expensive handlers yield. Render non-interactive content on the server, split interactive islands, mark heavy state updates as transitions so the click paints immediately, and move analytics or personalisation work out of the interaction path. Third-party tag deferral is frequently the single largest measurable win.

Does a Content Delivery Network alone fix LCP?

No. A CDN improves TTFB and static asset delivery, but it does not fix late resource discovery, oversized hero images, blocking scripts or client-side rendering of above-the-fold markup. Teams that add a CDN and stop there typically see one phase of LCP improve while render delay remains the dominant term.

How should Core Web Vitals budgets be enforced in CI?

Define per-route budgets for JavaScript transfer size, image weight and lab LCP, then fail pull requests that exceed them. Pair this with a nightly field check that alerts when p75 INP, LCP or CLS regresses beyond a set threshold. Budgets in CI prevent new debt; field alerts catch regressions caused by content, tags or third parties.