Web Performance Analysis
Expert knowledge for analyzing and optimizing web performance using industry-standard tools and metrics. Updated for Next.js 15 with framework-specific optimizations.
When to Use This Skill
- •Running performance audits on websites
- •Debugging Core Web Vitals issues (LCP, FCP, CLS, TBT)
- •Analyzing PageSpeed Insights or Lighthouse reports
- •Identifying performance bottlenecks
- •Creating optimization action plans
- •Optimizing Next.js 15 applications
Core Web Vitals Reference
| Metric | Good | Needs Improvement | Poor |
|---|---|---|---|
| LCP (Largest Contentful Paint) | ≤ 2.5s | 2.5s - 4.0s | > 4.0s |
| FCP (First Contentful Paint) | ≤ 1.8s | 1.8s - 3.0s | > 3.0s |
| CLS (Cumulative Layout Shift) | ≤ 0.1 | 0.1 - 0.25 | > 0.25 |
| TBT (Total Blocking Time) | ≤ 200ms | 200ms - 600ms | > 600ms |
| INP (Interaction to Next Paint) | ≤ 200ms | 200ms - 500ms | > 500ms |
Next.js 15 Performance Considerations
⚠️ Next.js 15 Breaking Changes to Consider:
1. Caching Behavior Changed
- •
fetch()is NOT cached by default (breaking change) - •Must explicitly opt-in with
cache: 'force-cache'ornext: { revalidate: N } - •Check if performance issues are caused by uncached data fetching
2. Partial Prerendering (PPR)
- •New experimental feature for optimal static/dynamic balance
- •Enables instant static shell with streamed dynamic content
- •Can significantly improve perceived performance
3. Streaming Metadata
- •Metadata no longer blocks UI rendering
- •Visual content appears faster
4. Server/Client Component Architecture
- •
priorityprop on<Image>only works in Server Components - •Client Component parents make ALL children Client Components
- •LCP preload must happen in
layout.tsxfor streamed pages
HTTP Request Patterns for Performance Analysis
Production sites often have WAF (CloudFront, Cloudflare, Vercel) that block requests without browser headers.
Always Use Browser Headers
bash
curl -s "https://example.com" \ -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36" \ -H "Accept: text/html"
If You Get 403/503 Errors
- •Inform the user the site has WAF/CDN protection
- •Ask for required headers (Cookie, Authorization, custom headers)
- •Retry with provided headers
Common Required Headers
- •
Cookie: session=...- For authenticated pages - •
Authorization: Bearer ...- For API-protected pages - •
X-Custom-Header: value- For custom WAF rules
Performance Analysis Commands
Check Resource Loading Order
bash
curl -s "URL" \ -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36" \ -H "Accept: text/html" \ | tr '>' '\n' | grep -n 'preload\|</head'
Check for Render-Blocking Resources
bash
curl -s "URL" \ -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36" \ -H "Accept: text/html" \ | grep -E '<script[^>]*src=|<link[^>]*stylesheet' | head -20
Check Image Optimization
bash
curl -s "URL" \ -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36" \ -H "Accept: text/html" \ | grep -i '<img' | head -10
LCP Optimization Checklist
General LCP Optimization
- •Identify the LCP element - Usually hero image, main heading, or video
- •Check preload placement - Must be in
<head>, not<body> - •Verify fetchPriority - LCP images should have
fetchPriority="high" - •Check loading attribute - Should be
loading="eager"notlazy - •Optimize image format - Use WebP/AVIF with fallbacks
- •Serve correct size - Use srcset and sizes attributes
- •Use CDN - Serve from edge locations
Next.js 15 LCP Optimization
- •Check component type - Is LCP element in Server or Client Component?
- •Verify preload location - Must use
ReactDOM.preload()inlayout.tsx - •Don't use
priorityin Client Components - Preload ends up in<body> - •Check parent components - Parent
"use client"makes children Client - •Consider PPR - Static shell with dynamic content streaming
- •Verify caching - Ensure data fetching uses
cache: 'force-cache'
Common Performance Issues
JavaScript Bundle Size
- •Symptom: High TBT, slow TTI
- •Fix: Code splitting, tree shaking, lazy loading
Unoptimized Images
- •Symptom: High LCP, slow page load
- •Fix: Compression, modern formats, responsive images
Render-Blocking CSS
- •Symptom: High FCP, slow initial render
- •Fix: Critical CSS inlining, async loading
Layout Shifts
- •Symptom: High CLS, content jumping
- •Fix: Reserve space for images/ads, use aspect ratios
Third-Party Scripts
- •Symptom: High TBT, slow interactions
- •Fix: Defer loading, use facade patterns, audit necessity
PageSpeed Insights API Usage
bash
# Basic analysis curl "https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=URL&strategy=mobile" # With API key (higher rate limits) curl "https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=URL&strategy=mobile&key=API_KEY"
Performance Budget Template
json
{
"performance": 90,
"metrics": {
"lcp": 2500,
"fcp": 1800,
"cls": 0.1,
"tbt": 200
},
"resources": {
"javascript": "200kb",
"css": "50kb",
"images": "500kb",
"total": "1mb"
}
}
Debugging Workflow
- •Gather baseline metrics - Run PageSpeed Insights or Lighthouse
- •Identify the bottleneck - What's the biggest opportunity?
- •Analyze root cause - Why is this metric poor?
- •Implement fix - Make targeted changes
- •Measure impact - Re-run analysis
- •Iterate - Address next biggest issue