Why Performance Matters
Web performance directly impacts business metrics:
- Amazon found that every 100ms of latency cost them 1% in sales
- Google confirmed that page speed is a ranking factor for both desktop and mobile search
- Walmart reported that for every 1-second improvement in load time, conversions increased by 2%
- 53% of mobile users abandon sites that take longer than 3 seconds to load (Google, 2024)
Performance is not an optimization — it's a feature.
Core Web Vitals (2025)
Google's Core Web Vitals are the key metrics:
Largest Contentful Paint (LCP)
Target: Under 2.5 seconds
Measures when the largest visible content element finishes rendering. To improve:
- Optimize and compress images (WebP/AVIF format)
- Use
for automatic optimizationnext/image - Preload critical resources (
)<link rel="preload"> - Reduce server response time (TTFB)
Interaction to Next Paint (INP)
Target: Under 200ms
Replaced FID in March 2024. Measures responsiveness to ALL interactions, not just the first. To improve:
- Break up long JavaScript tasks
- Use
for non-critical workrequestIdleCallback - Minimize main thread blocking
- Defer non-essential scripts
Cumulative Layout Shift (CLS)
Target: Under 0.1
Measures visual stability — how much the page layout shifts unexpectedly. To improve:
- Always set width/height on images and videos
- Reserve space for ads and dynamic content
- Use CSS
propertyaspect-ratio - Avoid injecting content above existing content
Image Optimization
Images account for 50% of total page weight on average (HTTP Archive, 2024).
Best practices:
- Use WebP (26% smaller than PNG) or AVIF (50% smaller than JPEG)
- Implement responsive images with
andsrcsetsizes - Lazy load below-the-fold images (
)loading="lazy" - Use
in Next.js — it handles optimization, lazy loading, and responsive sizing automaticallynext/image
JavaScript Optimization
- Code split — Only load JS needed for the current page
- Tree shaking — Remove unused code (automatic in webpack/Vite)
- Dynamic imports —
for heavy componentsimport() - Minimize third-party scripts — Each one adds to your bundle and blocks the main thread
- Use web workers for CPU-intensive tasks
Font Optimization
- Use
to prevent invisible text during loadingfont-display: swap - Subset fonts — Only include characters you need
- Self-host instead of loading from Google Fonts (eliminates DNS lookup)
- Preload critical fonts:
<link rel="preload" as="font">
Caching Strategy
- Static assets → Cache for 1 year with content hash in filename
- HTML → Cache briefly or revalidate (
)stale-while-revalidate - API responses → Cache based on data freshness requirements
- Use a CDN (Cloudflare, Vercel Edge, AWS CloudFront)
Measuring Performance
- Lighthouse — Built into Chrome DevTools
- PageSpeed Insights — Google's online tool with real-world data
- WebPageTest — Advanced waterfall analysis
- Chrome DevTools Performance tab — Frame-by-frame analysis
- Vercel Analytics — Real user monitoring for Next.js
The Performance Budget
Set limits and enforce them:
- Total page weight: Under 1.5MB
- JavaScript: Under 300KB (compressed)
- LCP: Under 2.5s
- INP: Under 200ms
- CLS: Under 0.1
"Performance is not a feature. It's a prerequisite." — Tim Kadlec