
next/image in 2026: 8 Tricks That Slash Your LCP and Kill Layout Shift
Most teams use next/image wrong. This guide reveals 8 advanced techniques—including priority hints, sizes attribute tuning, placeholder blurs, and remote patterns—that dramatically improve your Core Web Vitals and cut LCP in half.
Why Image Optimization Is Non-Negotiable
Images are the single biggest contributor to page weight. The average webpage is about 2MB, and images account for over half of that. The Next.js next/image component handles the hard parts automatically: WebP/AVIF conversion, responsive sizes, lazy loading, and preventing layout shift.
Basic Usage and Common Mistakes
import Image from 'next/image';
// CORRECT: always provide width and height for static images
function ProductCard({ product }) {
return (
<Image
src={product.imageUrl}
alt={product.name}
width={400}
height={300}
className="rounded-lg"
/>
);
}
// For above-the-fold images, disable lazy loading
function HeroImage() {
return (
<Image
src="/hero.jpg"
alt="Hero"
width={1200}
height={600}
priority // disables lazy load, adds preload link
/>
);
}
The most common mistake: using priority on every image. Only use it for LCP (Largest Contentful Paint) candidates — the main image visible on initial load.
Fill Mode for Responsive Containers
When you don't know exact dimensions, use fill with a positioned container:
function ArticleHero({ src, alt }) {
return (
<div className="relative aspect-video w-full">
<Image
src={src}
alt={alt}
fill
sizes="100vw"
className="object-cover"
/>
</div>
);
}
The Critical sizes Prop
The sizes prop tells the browser which image size to download before layout is computed. Getting this right can reduce image payload by 50%:
// For a full-width image on mobile, half on desktop
<Image
src="/article-hero.jpg"
alt="Article hero"
fill
sizes="(max-width: 768px) 100vw, 50vw"
/>
// For a grid of 3 on desktop, 1 on mobile
<Image
src={item.image}
alt={item.title}
width={400}
height={300}
sizes="(max-width: 640px) 100vw, (max-width: 1024px) 50vw, 33vw"
/>
Configuring Remote Images
// next.config.js
module.exports = {
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'images.unsplash.com',
},
{
protocol: 'https',
hostname: 'cdn.yourapp.com',
pathname: '/uploads/**',
},
],
// Optional: enable AVIF for even better compression
formats: ['image/avif', 'image/webp'],
// Cache optimized images longer
minimumCacheTTL: 60 * 60 * 24 * 30, // 30 days
},
};
Using a Custom CDN Loader
If you use Cloudinary or another image CDN, write a custom loader to get even better optimization:
// lib/cloudinary-loader.js
export function cloudinaryLoader({ src, width, quality }) {
const params = [
'f_auto', // automatic format (AVIF if supported)
'c_limit', // don't upscale
,
,
];
return ;
}
// Usage
<Image src="products/shoe.jpg" loader={cloudinaryLoader} ... />
Performance Impact
Properly configured, next/image typically delivers:
- 30-50% smaller images via WebP/AVIF vs JPEG/PNG
- Eliminates layout shift (CLS) by reserving space
- Lazy loading reduces initial page weight by 60-80%
priorityon LCP image improves LCP by 200-500ms
Image optimization is one of the highest-ROI performance improvements you can make — and Next.js automates most of it.
Get weekly highlights
No spam, unsubscribe anytime.
Dub.co
Short links & analytics for developers — track clicks, create branded links, manage affiliate URLs with ease.
Ranked.ai
AI-powered SEO & PPC service — fully managed, white hat, and built for modern search engines. Starting at $99/month.



Comments (0)
Sign in to comment
No comments yet. Be the first to comment!