The Web Performance Engineer optimises Core Web Vitals - Google's user-experience metrics that directly influence search rankings and conversion rates. LCP, CLS, and INP each have distinct causes and fixes. Diagnosis always comes before optimisation: open Chrome DevTools → Performance tab → record a page load, identify the bottleneck, then fix it.
Core Web Vitals Targets
| Metric | Good | Needs work | Primary causes |
|---|---|---|---|
| LCP (Largest Contentful Paint) | < 2.5s | > 4.0s | Render-blocking resources, slow server, unoptimised images |
| CLS (Cumulative Layout Shift) | < 0.1 | > 0.25 | Images without dimensions, late-loading fonts, injected content |
| INP (Interaction to Next Paint) | < 200ms | > 500ms | Long tasks on main thread, excessive JS, synchronous DOM updates |
LCP Optimisation
<!-- 1. Preload the LCP image - eliminates discovery delay -->
<link rel="preload" as="image" href="/hero.webp"
imagesrcset="/hero-480.webp 480w, /hero-960.webp 960w"
imagesizes="100vw" />
<!-- 2. Use WebP with fallback -->
<picture>
<source srcset="/hero-480.webp 480w, /hero-960.webp 960w" type="image/webp" />
<img src="/hero.jpg" alt="Hero" width="960" height="540"
loading="eager" fetchpriority="high" /> <!-- Never lazy-load LCP image -->
</picture>
<!-- 3. Inline critical CSS in <head> - eliminate render-blocking stylesheet -->
<style>
/* Only above-the-fold styles here - extracted with critical package */
body { margin: 0; font-family: system-ui; }
.hero { height: 100vh; background: #000; }
</style>
<link rel="preload" href="/main.css" as="style" onload="this.onload=null;this.rel='stylesheet'" />
CLS Fixes
/* Always set explicit dimensions on images and videos */
img {
width: 100%;
height: auto;
aspect-ratio: 16 / 9; /* Reserves space before image loads */
}
/* Font display swap - prevent layout shift from font loading */
@font-face {
font-family: 'Inter';
src: url('/fonts/inter.woff2') format('woff2');
font-display: optional; /* 'optional': no swap; 'swap': may shift */
}
/* Reserve space for dynamic content (ads, embeds) */
.ad-slot {
min-height: 250px; /* Known ad height */
contain: layout; /* Isolate from rest of layout */
}
INP Optimisation
- Break long tasks (>50ms) with
scheduler.yield()orsetTimeout(fn, 0)to yield to browser paint - Defer non-critical work after first interaction: analytics, chat widgets, non-visible components
- Use
startTransitionin React to mark state updates as non-urgent - keeps input responsive - Profile with Chrome DevTools → Performance → filter by "Long Tasks" - any task >50ms is a target