Why Speed Is a Business Problem
A slow page costs more than patience. It lowers conversion, raises bounce rates and, through Core Web Vitals, affects how Google ranks the page. Next.js gives you excellent tools for speed, but none of them work automatically: a Next.js site can be as slow as any other if images, JavaScript and data fetching are left unmanaged.
This guide covers the optimizations that usually make the biggest difference, in the order we recommend tackling them: measure first, then fix images, JavaScript, fonts, third-party scripts and caching.
Start With Measurement
Optimizing without data means fixing what is easy instead of what matters. Google evaluates three Core Web Vitals, and a page passes when at least 75% of real visits meet the "good" threshold:
| Metric | Measures | Good |
|---|---|---|
| LCP (Largest Contentful Paint) | How fast the main content appears | 2.5 s or less |
| INP (Interaction to Next Paint) | How quickly the page responds to input | 200 ms or less |
| CLS (Cumulative Layout Shift) | How much the layout jumps while loading | 0.1 or less |
Use two kinds of data. Field data from real users (Search Console, the Chrome UX Report, or the web-vitals library sending metrics to your analytics) tells you what visitors actually experience. Lab data from Lighthouse and Chrome DevTools tells you why. Always test on a throttled mid-range phone profile, because a fast developer laptop hides most problems.
Optimization Strategy
1. Image Optimization
Images are often the largest part of page weight and the most common cause of a slow LCP. The Next.js Image component handles modern formats, responsive sizes and lazy loading, provided it is configured correctly.
import Image from "next/image";
<Image
src="/hero.jpg"
alt="Hero"
width={1200}
height={600}
priority
sizes="(max-width: 768px) 100vw, 1200px"
/>
- Mark the LCP image with
priorityso it is preloaded instead of lazy-loaded. Use it for the hero image only; everything below the fold should stay lazy. - Always set
sizesfor responsive images. Without it the browser may download a desktop-sized file on a phone. - Always give dimensions (or use
fillinside a sized container) so the browser reserves space and the layout does not shift. - Compress the source files. The optimizer resizes and converts formats, but a 6 MB original still slows the first request and the build.
2. Code Splitting with Dynamic Imports
Every kilobyte of JavaScript must be downloaded, parsed and executed before the page becomes fully interactive, which is what INP measures. Split heavy components that are not needed on first render, such as a checkout modal or an analytics dashboard, into separate chunks that load only when needed.
const CheckoutModal = dynamic(() => import("@/components/CheckoutModal"), {
loading: () => <CheckoutSkeleton />,
ssr: false
});
With the App Router, the most effective step is to keep components as Server Components by default and add "use client" only where interactivity is required. Server Components send HTML, not JavaScript, so a mostly static page can ship very little client code.
Find out what is actually in your bundles with @next/bundle-analyzer. Common surprises include a full date or icon library imported for a single function, a charting library on pages without charts, and large JSON files bundled into client code.
3. Fonts and Third-Party Scripts
- Use
next/font. It self-hosts fonts, removes the extra connection to a font provider and sets fallback metrics so text does not jump when the web font loads. - Load third-party scripts deliberately with
next/script. Analytics, chat widgets and tag managers rarely need to block the page: usestrategy="afterInteractive"or"lazyOnload". - Audit tags regularly. Marketing tags accumulate over time and are a frequent cause of poor INP that no amount of code optimization will fix.
4. Caching Strategy
The fastest request is the one that never reaches your server. Choose a rendering mode per route based on how often its data changes:
| Content | Approach |
|---|---|
| Marketing pages, documentation | Static generation at build time |
| Product and category pages | Incremental Static Regeneration (time-based or on-demand revalidation) |
| Personalized dashboards, carts | Dynamic rendering with cached data fetches |
| API responses used by the browser | HTTP caching with stale-while-revalidate |
On-demand revalidation is usually the best fit for content managed in a CMS: publish an article or change a price, trigger revalidation for the affected paths, and every other visitor gets a cached page. Put a CDN in front of the application so static assets and cached pages are served close to the user.
5. Server Response Time
A slow Time to First Byte delays everything else. Fetch independent data in parallel rather than one request after another, add indexes for the queries your pages run most, and stream slower sections with Suspense so the rest of the page renders immediately instead of waiting for the slowest query.
Keep It Fast
Performance degrades quietly: a new dependency here, a larger image there. Protect it the same way you protect functionality:
- Set a performance budget (for example, a maximum JavaScript size per route) and check it in CI.
- Run Lighthouse CI on key pages for every pull request.
- Keep collecting field data and review Core Web Vitals monthly, per page template rather than only site-wide.
Performance Checklist
- Field data collected and the worst page templates identified
- LCP image marked with
priority; all images sized and givensizes - Server Components by default; heavy client components loaded dynamically
- Bundle analyzed and oversized dependencies replaced
- Fonts loaded with
next/font; third-party scripts deferred - Rendering and caching strategy chosen per route; CDN in front
- Performance budget enforced in CI
Key Takeaways
Performance optimization is about dozens of small improvements that compound. Focus on the biggest offenders first: usually images and unused JavaScript.
Measure with real-user data, fix the largest problems first, and add checks that stop regressions from creeping back in. If your Next.js application needs a performance review, talk to our team or see our web development services.