Skip to content
Now accepting Q2 projects — limited slots available. Get started →
Performance · Updated Apr 30, 2026

What is Image Optimization?

Image optimization is a set of techniques that reduce image file size and improve page load performance.

What is Image Optimization?

Image optimization is reducing file size and delivering the right format, resolution, and dimensions for each user's device. Images account for 40-60% of a page's total weight (HTTP Archive), making them the biggest culprit in slow load times. Key techniques: lossy and lossless compression, modern formats (WebP, AVIF), responsive srcset delivery, lazy loading below-the-fold content. Google's Largest Contentful Paint (LCP) metric—one of three Core Web Vitals—directly measures how fast the largest visible element (often a hero image) renders. You need 2.5 seconds or less for a "good" score. On projects we've shipped, switching from unoptimized PNGs to properly sized AVIF images cut hero payloads by 70-85%. We routinely hit sub-1.5s LCP on 4G connections.

How it works

Image optimization happens across three layers: format, compression, and delivery.

Format selection

Modern formats encode pixels more efficiently. WebP (released by Google in 2010, broadly supported since ~2020) gives you 25-35% smaller files than JPEG at equivalent quality. AVIF (based on AV1, supported in Chrome since v85 and Safari since 16.0) goes further—typically 30-50% smaller than WebP for photos. For simple graphics and icons, SVG's still the best choice since it's resolution-independent.

Compression

Lossy compression (e.g., quality: 75 in Sharp or Squoosh) throws away data your eye won't miss. Lossless compression removes redundant data without quality loss. Tools like Sharp (the library behind Next.js Image) let you set quality per format:

import sharp from 'sharp';

await sharp('hero.png')
  .resize(1200, 630, { fit: 'cover' })
  .avif({ quality: 65 })
  .toFile('hero.avif');

Delivery

Responsive images via srcset and sizes attributes mean the browser downloads only the resolution it needs. A 375px-wide phone shouldn't pull down a 2400px image. The <picture> element with <source> tags lets you serve AVIF to supporting browsers with WebP or JPEG fallbacks.

CDNs like Cloudflare Images, Imgix, and Vercel's built-in image optimization handle format negotiation, resizing, and caching at the edge. You upload one source file and the CDN does the rest via content negotiation with the Accept header.

When to use it

Honest answer: always. Every production site should optimize images. The specific techniques vary, though.

Go aggressive when:

  • Hero images or product photos are your LCP element
  • You're targeting mobile users on constrained networks
  • Your page has 10+ images (galleries, e-commerce PLPs)
  • Core Web Vitals scores are failing the 75th percentile threshold

Lighter-touch when:

  • Images are small UI icons (consider inline SVG instead)
  • You're behind a CDN that already handles format conversion
  • Content is user-generated and you need to balance processing cost vs. savings

Skip manual optimization when:

  • You're using Next.js <Image> (or Astro's <Image>)—these components handle resizing, format selection, and lazy loading out of the box. We default to these on every project. Only drop to manual Sharp pipelines for edge cases like OG image generation.

Image Optimization vs alternatives

Approach Pros Cons
Manual (Sharp, Squoosh CLI) Full control over quality/format, no runtime cost Requires build step, manual srcset management
Framework built-in (Next.js Image, Astro Image) Zero-config, automatic format negotiation, lazy loading Tied to framework, serverless function cost on Vercel
CDN-based (Cloudflare Images, Imgix) Edge delivery, on-the-fly transforms, no build step Monthly cost, vendor lock-in on URL structure
CMS plugins (WordPress Smush, ShortPixel) Easy for non-developers Limited format support, adds plugin weight

Our preferred stack: Astro's <Image> component for static sites, Next.js <Image> for dynamic apps, with Cloudflare as the CDN layer. We've shipped this combo on 50+ projects and it consistently gets LCP under 2s without manual tuning.

Real-world example

On a recent e-commerce rebuild (Astro + Shopify Storefront API), the existing site served uncompressed 2400×1600 JPEG product images at ~1.8 MB each. The product listing page loaded 24 images above and below the fold—total image payload was 18+ MB.

We applied three changes: converted to AVIF with WebP fallback via Astro's <Image>, generated srcset breakpoints at 400/800/1200px widths, and added loading="lazy" to everything except the first four visible products. Result: average image size dropped to ~85 KB, total page image payload went from 18 MB to 1.2 MB, and LCP on mobile (Moto G Power on 4G, tested via WebPageTest) dropped from 5.8s to 1.4s. Lighthouse performance score jumped from 38 to 94.

Frequently asked questions about Image Optimization

Is image optimization the same as lazy loading?
No. Lazy loading is one technique within the broader image optimization toolkit. Lazy loading defers the download of off-screen images until the user scrolls near them, using the `loading="lazy"` attribute (supported natively since Chrome 77 and all major browsers by 2021). Image optimization also includes format conversion (WebP, AVIF), compression quality settings, responsive sizing via srcset, and CDN-based delivery. Lazy loading alone won't help if your images are 2 MB each — you need compression and format selection too. Conversely, well-compressed images that all load eagerly will still hurt Time to First Byte and bandwidth on image-heavy pages.
When did modern image formats become standard for the web?
WebP reached practical universality around 2020 when Safari 14 added support — it had been available in Chrome since 2014 but Safari's holdout blocked adoption. AVIF support landed in Chrome 85 (August 2020) and Safari 16 (September 2022). By mid-2023, AVIF had enough browser coverage (~92% per caniuse) that most teams started adopting it as the primary format with WebP as fallback. As of April 2026, AVIF is our default for photographic content on every new project. The key milestone was Safari 16 — once Apple shipped AVIF support, the format crossed the adoption threshold for production use without significant fallback concerns.
What's the best alternative to manual image optimization?
Framework-level components like Next.js `<Image>` (introduced in Next.js 10, October 2020, significantly improved in Next.js 13+) and Astro's `<Image>` component. These handle format negotiation, responsive sizing, and lazy loading with zero manual configuration. If you're not on one of these frameworks, CDN-based solutions like Cloudflare Images or Imgix are the next best option — you upload a single high-res source and the CDN generates optimized variants on the fly based on the client's Accept header and viewport hints. The trade-off is cost: CDN image services typically charge per transformation or per unique image served, which adds up on high-traffic sites with large catalogs.
Does image optimization affect SEO rankings?
Yes, directly. Google uses Core Web Vitals — specifically LCP — as a ranking signal, and images are the LCP element on roughly 70-80% of web pages. A slow-loading hero image means a poor LCP score, which can hurt rankings, particularly on mobile where Google uses mobile-first indexing. Beyond LCP, optimized images reduce Cumulative Layout Shift (CLS) when you specify explicit `width` and `height` attributes, preventing layout jumps as images load. There's also an indirect effect: faster pages have lower bounce rates and higher engagement, which are behavioral signals Google considers. We've seen pages move from position 8-12 to position 3-5 after fixing image optimization issues alone, though results vary by niche and competition.
Get in touch

Let's build
something together.

Whether it's a migration, a new build, or an SEO challenge — the Social Animal team would love to hear from you.

Get in touch →