Image Optimization
Learn what image optimization is, how it improves page speed and Core Web Vitals, and best practices for compressing and serving images on the web.
Image optimization is the process of reducing image file sizes and improving delivery without significantly degrading visual quality. It encompasses format selection (choosing between JPEG, PNG, WebP, and ), compression level tuning, responsive sizing (serving appropriately sized images for each device), and delivery optimization (lazy loading, CDN distribution, and proper caching). Images typically account for 40-60% of a page’s total weight, making them the largest optimization opportunity for most websites.), compression level tuning, responsive sizing (serving appropriately sized images for each device), and delivery optimization (lazy loading, CDN distribution, and proper caching). Images typically account for 40-60% of a page’s total weight, making them the largest optimization opportunity for most websites.
Why It Matters for SEO
Unoptimized images are the most common cause of slow page speed and poor Core Web Vitals scores. The Largest Contentful Paint (LCP) element is an image on most pages, meaning image optimization directly determines your LCP score — a Google ranking factor. Oversized images also increase bandwidth costs, drain mobile users’ data plans, and significantly worsen the experience on slower connections.
Well-optimized images also perform better in Google Image Search, which drives substantial traffic for many sites. Properly sized, compressed images with descriptive alt text and appropriate file names are more likely to be featured in image search results and image packs within regular search results.
How to Optimize Images
Choose the right format for each image type: use AVIF or WebP for photographs and complex images, SVG for icons and logos, and PNG only when transparency is required and AVIF/WebP are not suitable. Use the <picture> element to serve modern formats with JPEG fallbacks.
Implement responsive images using the srcset and sizes attributes so browsers download only the size they need. A 400px-wide mobile screen should not download a 2400px-wide desktop image. Lazy load images below the fold using loading="lazy", but never lazy load the LCP image — it should load eagerly with fetchpriority="high".
Compress images during your build process or via an image CDN. Tools like Sharp, Squoosh, or cloud-based services can automate compression at consistent quality levels. Set long cache headers (at least one year) for immutable image assets with content-hash filenames.
Common Mistakes
- Lazy loading the LCP image: The hero image or main content image that serves as the LCP element must load immediately. Lazy loading it delays LCP and hurts your Core Web Vitals score.
- Serving one size for all devices: Without responsive images, mobile users download desktop-sized images that waste bandwidth and slow their experience significantly.
- Using PNG for photographs: PNG is lossless and produces enormous file sizes for photographic content. Use lossy AVIF, WebP, or JPEG instead.
- Not setting width and height attributes: Missing dimensions cause CLS as the browser cannot reserve space for the image until it loads, resulting in layout shifts.
- Over-compressing images: Aggressive compression saves bytes but introduces visible artifacts, particularly around text overlays and sharp edges. Find the quality threshold where file size reduction no longer justifies the visual degradation.
Image optimization is one of the highest-impact performance improvements you can make, directly affecting Core Web Vitals, user experience, and search visibility.