Engineering Sub-Second Core Web Vitals (LCP, INP & CLS)
Code-level engineering techniques to hit green Core Web Vitals on mobile: preloading LCP assets, cutting main-thread JS, and locking layout shift.
Core Web Vitals are no longer a nice-to-have lighthouse badge—they directly shape mobile bounce rates, paid-ad quality scores, and competitive tie-breakers in Google Search. Reaching green scores across real-user Chrome UX Report (CrUX) data requires fixing the root causes in HTML, CSS, and JavaScript rather than installing caching plugins.
Fixing Largest Contentful Paint (LCP < 2.5s)
Identify your above-the-fold hero element first. Never lazy-load the hero image; instead, give it explicit width and height attributes, serve modern AVIF/WebP or inline SVG graphics, and eliminate render-blocking third-party stylesheets. Pair that with edge HTML caching so TTFB stays below 200 ms.
Conquering Interaction to Next Paint (INP < 200ms)
INP replaced FID to measure every tap, click, and keypress across the entire page lifecycle. Heavy hydration bundles, unthrottled scroll listeners, and synchronous DOM mutations block the main thread and make mobile buttons feel sluggish. Ship minimal vanilla JS or island architecture, defer non-critical analytics, and break heavy computations into Web Workers or requestAnimationFrame chunks.
Eliminating Cumulative Layout Shift (CLS < 0.1)
Layout shifts happen when late-loading images, web fonts, or cookie banners push content downward after first paint. Always reserve aspect-ratio boxes for media, use font-display: swap with matched fallback metrics, and render modals or banners in fixed overlay layers rather than injecting them at the top of the document flow.