Skip to content
Back to Blog

How to Optimize Images for SEO and Page Speed in 2026

February 24, 2026
15 min read

Learn how image optimization directly impacts your Google rankings through Core Web Vitals. Covers format selection, compression, lazy loading, responsive images, and alt text best practices.

Joseph Hamawi

Joseph Hamawi

Founder, Kode Foundry · February 24, 2026

Builds browser-based image and PDF tools at Pixly, the consumer brand of Kode Foundry LTD. Privacy-first by default — files are processed in your browser, not on a server.

Why Image Optimization Is an SEO Ranking Factor

Google has made page speed a direct ranking factor through Core Web Vitals. Since images typically account for 50% or more of a page's total weight, image optimization is one of the highest-impact SEO improvements you can make.

The three Core Web Vitals metrics most affected by images:

Largest Contentful Paint (LCP): Measures how quickly the largest visible element loads, usually a hero image or featured image. Google's target: under 2.5 seconds. Unoptimized images are the #1 cause of poor LCP scores.

Cumulative Layout Shift (CLS): Measures visual stability. Images without defined dimensions cause layout shifts as they load, pushing content around and frustrating users. Google's target: under 0.1.

Interaction to Next Paint (INP): While less directly related to images, heavy images can block the main thread during decode, delaying interactivity.

The Business Impact

Studies consistently show that page speed affects user behavior and business metrics:

  • A 1-second delay in page load reduces conversions by 7%
  • 53% of mobile users abandon sites that take more than 3 seconds to load
  • Amazon found that every 100ms of latency cost them 1% in sales
  • Google found that as page load time increases from 1 to 3 seconds, bounce rate increases by 32%

Image optimization is often the single biggest lever for improving these numbers.

Step 1: Choose the Right Format

Format selection alone can reduce image size by 30-60% with no visible quality difference:

| Image Type | Recommended Format | Fallback | |-----------|-------------------|----------| | Photographs | AVIF → WebP → JPEG | JPEG | | Screenshots with text | PNG | WebP lossless | | Logos and icons | SVG | PNG-8 | | Simple graphics | SVG or PNG-8 | PNG | | Animated images | WebP animated | GIF (last resort) | | Transparent photos | WebP → AVIF | PNG |

Implementation with the Picture Element

<picture>
  <source srcset="hero.avif" type="image/avif">
  <source srcset="hero.webp" type="image/webp">
  <img src="hero.jpg" alt="Product showcase"
       width="1200" height="800"
       loading="lazy"
       decoding="async">
</picture>

This serves the smallest format each browser supports while maintaining universal compatibility.

Step 2: Compress Appropriately

Compression reduces file size by removing data the viewer won't notice. The key is finding the right quality level for each use case.

Recommended Quality Settings by Format

| Format | Quality Setting | Typical Savings | |--------|---------------|----------------| | JPEG | 82-88% | 60-75% vs uncompressed | | WebP | 75-82% | 70-80% vs uncompressed | | AVIF | 60-72% | 80-88% vs uncompressed | | PNG | Maximum compression level | 40-70% vs uncompressed |

Important: AVIF quality numbers aren't directly comparable to JPEG numbers. AVIF 65% produces similar visual quality to JPEG 85%.

How to Find the Optimal Quality

  1. Start at the highest quality setting
  2. Reduce quality in 5% increments
  3. Compare each version side-by-side at actual display size
  4. Stop when you first notice quality degradation
  5. Use the setting one step above that point

For most photographs, this lands at JPEG 82-85%, WebP 78-82%, or AVIF 62-68%.

Step 3: Serve Correctly Sized Images

Serving a 4000×3000 image for a 400×300 display slot wastes bandwidth and slows page load. The browser downloads the full-size image, then discards 99% of the pixels.

Responsive Images with srcset

The srcset attribute lets the browser choose the most appropriate image size:

<img srcset="product-400w.webp 400w,
             product-800w.webp 800w,
             product-1200w.webp 1200w,
             product-1600w.webp 1600w"
     sizes="(max-width: 600px) 100vw,
            (max-width: 1200px) 50vw,
            400px"
     src="product-800w.webp"
     alt="Blue running shoes"
     width="800" height="600"
     loading="lazy">

The browser evaluates the viewport width, device pixel ratio, and sizes attribute to download only the image variant it needs.

Common Responsive Breakpoints

Generate image variants at these widths to cover most use cases:

| Width | Target | |-------|--------| | 400px | Mobile thumbnails, small cards | | 800px | Mobile full-width, tablet cards | | 1200px | Tablet full-width, desktop cards | | 1600px | Desktop full-width, hero images | | 2400px | Retina desktop full-width |

Step 4: Implement Lazy Loading

Images below the fold (not visible on initial page load) should be loaded lazily, only when the user scrolls near them.

Native Lazy Loading

The simplest approach, one attribute:

<img src="product.webp" alt="Product" loading="lazy">

Critical rule: Never lazy-load the LCP image (usually your hero or above-the-fold featured image). The LCP image should load as early as possible.

<!-- Hero image: load eagerly, preload for fastest LCP -->
<link rel="preload" as="image" href="hero.avif" type="image/avif">
<img src="hero.avif" alt="Hero" loading="eager" fetchpriority="high">

<!-- Below-fold images: lazy load -->
<img src="product1.webp" alt="Product 1" loading="lazy">
<img src="product2.webp" alt="Product 2" loading="lazy">

The fetchpriority Attribute

For your most important image (usually LCP), add fetchpriority="high" to tell the browser to prioritize it:

<img src="hero.webp" alt="Hero" fetchpriority="high" loading="eager">

For decorative or less important visible images, fetchpriority="low" prevents them from competing with the LCP image for bandwidth.

Step 5: Always Specify Dimensions

Images without explicit width and height attributes cause layout shifts (CLS) as the browser doesn't know how much space to reserve until the image loads.

<!-- Bad: causes layout shift -->
<img src="photo.webp" alt="Photo">

<!-- Good: reserves space, prevents CLS -->
<img src="photo.webp" alt="Photo" width="1200" height="800">

For responsive layouts, combine explicit dimensions with CSS:

img {
  width: 100%;
  height: auto;
  aspect-ratio: attr(width) / attr(height);
}

This reserves the correct aspect ratio space while allowing the image to resize fluidly.

Step 6: Write Effective Alt Text

Alt text serves three purposes: accessibility (screen readers), SEO (search engines), and fallback (when images fail to load).

Alt Text Best Practices

Do:

  • Describe what the image shows, not what it is
  • Include relevant keywords naturally
  • Keep it concise (125 characters or fewer)
  • Be specific, "Red Nike Air Max 90 running shoes" not "shoes"
  • Match the context, the same image might need different alt text on different pages

Don't:

  • Start with "Image of..." or "Photo of..." (screen readers already announce it as an image)
  • Stuff keywords unnaturally
  • Leave alt text empty for meaningful images
  • Use the filename as alt text

Examples

| Bad | Good | |-----|------| | alt="" | alt="Woman jogging on beach at sunrise" | | alt="photo" | alt="2026 MacBook Pro 16-inch on wooden desk" | | alt="product image shoes buy now" | alt="Nike Air Max 90 in university red colorway" | | alt="IMG_4592.jpg" | alt="Golden Gate Bridge in morning fog" |

Decorative Images

For purely decorative images (background textures, dividers, visual flourishes), use an empty alt attribute:

<img src="divider.svg" alt="" role="presentation">

This tells screen readers to skip the image entirely.

Step 7: Use a CDN for Image Delivery

A Content Delivery Network serves your images from servers geographically close to each visitor, reducing latency:

  • A user in Tokyo gets images from a Tokyo server
  • A user in London gets images from a London server
  • Typical improvement: 100-500ms faster per image

Popular CDN options with image optimization: Cloudflare, Fastly, AWS CloudFront, Bunny CDN.

Many CDNs also offer automatic format conversion, they detect the browser's capabilities and serve the optimal format (AVIF, WebP, or JPEG) without requiring you to generate multiple versions.

Step 8: Optimize Image Metadata

Remove unnecessary metadata to reduce file size:

  • EXIF data: Camera settings, GPS coordinates, timestamps. Typically 10-50 KB per image. Remove unless needed (e.g., photography portfolio).
  • Color profiles: Embedded ICC profiles can add 2-5 KB. Convert to sRGB and strip the profile for web images.
  • Thumbnails: JPEG files often contain embedded preview thumbnails. Stripping them saves 5-20 KB.

Privacy note: Always strip GPS data from images before publishing online unless you specifically want to share location information.

Performance Audit Checklist

Run through this checklist for every page:

  1. LCP image optimized: Hero/featured image is compressed, correctly sized, and preloaded
  2. Modern formats used: AVIF with WebP and JPEG fallbacks via <picture>
  3. Responsive images: srcset and sizes attributes on all content images
  4. Lazy loading: All below-fold images have loading="lazy"
  5. Dimensions specified: Width and height attributes on every <img> tag
  6. Alt text present: Descriptive alt text on all meaningful images
  7. Compression verified: Each image format at optimal quality level
  8. No oversized images: No images significantly larger than their display size
  9. CDN delivery: Images served from edge locations
  10. Metadata stripped: Unnecessary EXIF data and color profiles removed

Measuring Results

Use these tools to verify your optimization:

  • PageSpeed Insights: Google's tool that measures Core Web Vitals and provides image-specific recommendations
  • Chrome DevTools: Network tab shows individual image sizes and load times
  • WebPageTest: Detailed waterfall view showing exactly when each image loads
  • Lighthouse: Built into Chrome DevTools, scores your page and identifies optimization opportunities

Target Metrics

| Metric | Good | Needs Improvement | Poor | |--------|------|-------------------|------| | LCP | < 2.5s | 2.5-4.0s | > 4.0s | | CLS | < 0.1 | 0.1-0.25 | > 0.25 | | Total image weight | < 500 KB | 500 KB - 1.5 MB | > 1.5 MB | | Largest image | < 200 KB | 200-500 KB | > 500 KB |

Image optimization is not a one-time task, it's an ongoing practice. Every new image added to your site should follow these guidelines. Tools like Pixly make the compression and format conversion part easy, handle everything locally in your browser, choose the optimal format, and download optimized images ready for production.

Ready to Convert Your Images?

Fast, secure, and completely free. Try our converter now!

Start Converting

Related Articles