core web vitals
Practical techniques for achieving perfect Lighthouse scores in production. No tricks, just engineering.
Perfect Lighthouse scores aren't just for toy demos. Here's how we consistently ship production apps that score 100 on SEO and 98+ on Performance.
Start with constraints:
These aren't suggestions. They're requirements.
Client-side JavaScript is the enemy of performance. Use Next.js Server Components by default. Ship HTML that works without JS.
// ❌ Client-heavy
'use client'
export default function Page() {
const [data, setData] = useState(null)
useEffect(() => {
fetch('/api/data').then(r => setData(r))
}, [])
return {data?.title}
}
// ✅ Server-first
export default async function Page() {
const data = await fetchData()
return {data.title}
}
Images kill performance. Use next/image with proper sizing:
<Image
src="/hero.jpg"
alt="Hero"
width={1200}
height={600}
priority // Above fold
sizes="(max-width: 768px) 100vw, 1200px"
/>
Key wins:
Web fonts block rendering. Use Next.js font optimization:
import { Inter } from 'next/font/google'
const inter = Inter({
subsets: ['latin'],
display: 'swap', // Prevent FOIT
preload: true,
})
Tell the browser what's coming:
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="dns-prefetch" href="https://api.example.com" />
Every dependency costs performance. Audit regularly:
npx @next/bundle-analyzer
Questions to ask:
Use ISR (Incremental Static Regeneration) for content:
export const revalidate = 3600 // Revalidate hourly
Add Cloudflare in front for edge caching. Purge on content updates.
Reserve space for dynamic content:
// ❌ Causes CLS
<div className="dynamic-height">
{loading ? <Spinner /> : <Content />}
</div>
// ✅ Fixed height
<div className="h-96">
{loading ? <Spinner /> : <Content />}
</div>
Lighthouse scores in CI don't guarantee real-user performance. Use Real User Monitoring:
Perfect scores aren't magic. They're the result of disciplined engineering and performance-first architecture.
Performance is one half of the ranking story. For the full picture — crawlability, schema, AI search readiness, and a 90-day remediation roadmap — see the technical SEO audit service, which pairs Lighthouse diagnosis with SEMrush and DataForSEO signals.