Clarity

How to Optimize Images for SEO and Speed

Summary: To optimize images for SEO and speed, use modern formats like WebP or AVIF, compress every image before uploading, add descriptive file names and alt text, implement responsive images with srcset, enable lazy loading, and serve images via a CDN. Unoptimized images are the #1 cause of slow websites — the HTTP Archive reports that images account for nearly 50% of the average page's total weight.

Images make content engaging, improve user experience, and drive traffic from Google Image Search. But unoptimized images are also the single biggest performance killer on the web. A page loaded with 4MB of uncompressed PNGs doesn't just feel slow — it ranks lower in Google, bounces mobile users, and tanks your Core Web Vitals scores.

The good news: image optimization is one of the highest-impact, lowest-effort improvements you can make. According to web.dev's performance guide, properly optimizing images can reduce page weight by 50–80%, cutting load times dramatically. This guide walks you through every technique — from choosing the right format to measuring results with Lighthouse.

Why Image Optimization Matters

Page Speed and Rankings

Google has confirmed that page speed is a ranking factor — first for desktop in 2018 and then for mobile in the "Speed Update." With the introduction of Core Web Vitals as ranking signals in 2021, performance became even more important. The Largest Contentful Paint (LCP) metric — which measures how quickly your main content loads — is heavily influenced by image optimization because the LCP element is often a hero image or banner.

A Google study on Core Web Vitals found that sites meeting all three Core Web Vitals thresholds saw 24% fewer page abandonments. Since images are typically the heaviest resources on a page, optimizing them is the fastest path to better LCP scores and lower bounce rates.

User Experience and Conversions

Slow-loading images create a terrible user experience. Content shifts around as images load (Cumulative Layout Shift), users see blank spaces or broken placeholders, and mobile visitors on slower connections may leave before the page fully renders. Amazon famously found that every 100ms of latency cost them 1% in sales. For most websites, images are the easiest lever to pull for dramatic speed improvements.

Google Image Search Traffic

Google Image Search is the second-largest search engine in the world. According to Google's image SEO best practices, properly optimized images with descriptive file names, alt text, and surrounding context can drive significant organic traffic from image search. If you're not optimizing images for SEO, you're leaving an entire traffic channel on the table.

Image Formats: JPEG vs PNG vs WebP vs AVIF

Choosing the right image format is the foundation of image optimization. Each format has specific strengths:

JPEG (.jpg / .jpeg)

Best for: Photographs, complex images with many colours, hero images, product photos.

JPEG uses lossy compression — it discards some image data to achieve smaller file sizes. At quality settings of 75–85%, the visual difference is imperceptible to most users while file sizes shrink dramatically. JPEG doesn't support transparency, so it's not suitable for logos or icons that need transparent backgrounds. It remains the most universally supported format and is a safe default for photographs.

PNG (.png)

Best for: Graphics with transparency, logos, icons, screenshots, images with text overlays.

PNG uses lossless compression — no quality is lost, but file sizes are significantly larger than JPEG for photographs. PNG-24 supports full alpha transparency, making it essential for logos and UI elements that need to sit on different backgrounds. However, using PNG for photographs is a common mistake that results in files 5–10x larger than necessary. If you don't need transparency, use JPEG or WebP instead.

WebP (.webp)

Best for: Almost everything — it's the modern replacement for both JPEG and PNG.

WebP, developed by Google, supports both lossy and lossless compression, transparency, and animation. It produces files 25–35% smaller than equivalent-quality JPEGs and significantly smaller than PNGs. According to Can I Use, WebP is now supported by over 97% of browsers globally, including Chrome, Firefox, Safari, and Edge. Unless you need to support very old browsers, WebP should be your default format.

AVIF (.avif)

Best for: Maximum compression with high visual quality — the next generation after WebP.

AVIF is based on the AV1 video codec and offers even better compression than WebP — typically 30–50% smaller files than JPEG at equivalent quality. It supports transparency, HDR, and wide colour gamuts. The main drawback is browser support: while Chrome, Firefox, and Safari support it, AVIF browser support is around 93% globally. Encoding is also slower than WebP. Use AVIF as a progressive enhancement with WebP or JPEG fallbacks using the <picture> element.

SVG (.svg)

Best for: Icons, logos, simple illustrations, and any graphic that needs to scale to any size.

SVG is a vector format — it uses mathematical paths instead of pixels, meaning it scales infinitely without quality loss. SVG files for simple graphics are often just a few kilobytes. Use SVGs for your logo, navigation icons, and decorative elements. Don't use SVG for photographs — it's not designed for that and the files would be enormous.

Format Decision Cheat Sheet

  • Photograph, no transparency needed: WebP (JPEG fallback)
  • Photograph, maximum compression: AVIF (WebP fallback → JPEG fallback)
  • Image with transparency: WebP (PNG fallback)
  • Logo or icon: SVG
  • Simple animation: WebP or lightweight GIF alternative (Lottie)
  • Screenshot with text: WebP lossless (PNG fallback)
  • Image Compression Tools

    Compression is non-negotiable. Every image on your site should be compressed before upload. Here are the best tools available:

    Online Tools

  • TinyPNG / TinyJPG: Browser-based lossy compression that typically reduces file sizes by 60–80% with minimal visible quality loss. Free for up to 20 images at a time. Supports WebP output. Ideal for quick one-off compression.
  • Squoosh (by Google): Open-source tool at squoosh.app that lets you compare formats side-by-side with a visual diff slider. Supports AVIF, WebP, JPEG, PNG, and more. Runs entirely in your browser — no uploads to servers. Best for understanding the quality/size tradeoffs of different formats and settings.
  • ShortPixel: WordPress plugin and web service that automatically compresses images on upload. Supports lossy, glossy, and lossless compression modes. Converts to WebP and AVIF automatically. Free tier includes 100 images/month. Excellent for WordPress sites that need hands-off optimization.
  • Desktop Tools

  • ImageOptim (macOS): Free, open-source batch optimizer that strips metadata and applies lossless compression. Drag-and-drop interface. Can reduce file sizes by 20–50% without any quality loss. Should be part of every designer's workflow.
  • RIOT (Windows): Free image optimizer with side-by-side preview. Supports JPEG, PNG, and GIF with manual quality control.
  • Build-Time / Automated Tools

  • Next.js Image component: Automatically serves images in WebP/AVIF with responsive sizing, lazy loading, and blur placeholders. If you're using Next.js, this should be your primary image delivery method.
  • Sharp (Node.js): High-performance image processing library used by Next.js under the hood. Can resize, crop, convert, and compress images in build pipelines.
  • Cloudinary: Cloud-based image CDN that automatically optimizes, resizes, and converts images on the fly via URL parameters. The Cloudinary optimization documentation covers auto-format, auto-quality, and responsive breakpoint generation. Excellent for sites with large image libraries.
  • Responsive Images: srcset and sizes

    Serving a 2400px-wide image to a 375px mobile screen wastes enormous bandwidth. Responsive images solve this by letting the browser choose the appropriate image size for the device.

    The srcset Attribute

    The srcset attribute provides the browser with multiple image sources at different widths:

    <img src="hero-800.webp" srcset="hero-400.webp 400w, hero-800.webp 800w, hero-1200.webp 1200w, hero-1600.webp 1600w" sizes="(max-width: 600px) 100vw, (max-width: 1200px) 80vw, 1200px" alt="Hero image description" loading="lazy" width="1600" height="900" />

    The sizes attribute tells the browser how wide the image will be displayed at different viewport sizes. The browser then selects the smallest image from srcset that's large enough for the display size and pixel density.

    The <picture> Element for Format Fallbacks

    Use <picture> to serve next-gen formats with automatic fallbacks:

    <picture> <source type="image/avif" srcset="hero.avif" /> <source type="image/webp" srcset="hero.webp" /> <img src="hero.jpg" alt="Hero image description" width="1600" height="900" loading="lazy" /> </picture>

    The browser uses the first <source> it supports. Browsers that support AVIF get the smallest file; others fall back to WebP, then JPEG. This approach gives every visitor the best format their browser can handle.

    Lazy Loading

    Lazy loading defers the loading of images until they're about to enter the viewport. This is critical for pages with many images because it dramatically reduces initial page load time — the browser only downloads what the user can actually see.

    Native Lazy Loading

    Modern browsers support lazy loading natively with a single HTML attribute:

    <img src="product.webp" alt="Product photo" loading="lazy" width="800" height="600" />

    Important: Do NOT lazy-load your above-the-fold images (hero images, logos, or anything visible without scrolling). These should load immediately. Set loading="eager" (the default) or use fetchpriority="high" for your LCP image to tell the browser to prioritize it:

    <img src="hero.webp" alt="Main banner" fetchpriority="high" width="1600" height="900" />

    Always Include Width and Height

    Always include explicit width and height attributes on your <img> tags. This allows the browser to reserve the correct space before the image loads, preventing Cumulative Layout Shift (CLS). Without dimensions, the browser doesn't know how tall the image will be until it downloads, causing the page content to jump around as images pop in.

    CDN for Image Delivery

    A Content Delivery Network (CDN) serves images from servers physically close to the user, dramatically reducing latency. Instead of every visitor downloading images from your origin server (which might be on the other side of the world), they get them from a nearby edge node.

    Modern image CDNs go beyond simple caching. Services like Cloudinary, Imgix, and Cloudflare Images can automatically:

  • Convert images to the optimal format based on the visitor's browser (WebP for Chrome, AVIF for supported browsers, JPEG fallback)
  • Resize images on the fly via URL parameters
  • Apply quality optimization automatically
  • Strip unnecessary metadata
  • Add cache headers for repeat visits
  • Even if you're on a budget, Cloudflare's free plan includes a CDN that caches static assets including images. For WordPress sites, plugins like WP Super Cache or W3 Total Cache can integrate with CDNs automatically.

    Image SEO: File Names, Alt Text, and Context

    Technical optimization gets images loading fast, but image SEO gets them ranking. Here's how to make your images discoverable in search.

    Descriptive File Names

    Google uses file names to understand image content. Rename your files before uploading:

  • Bad: IMG_20260310_143022.jpg or photo1.png
  • Good: iphone-15-screen-repair-before-after.webp
  • Use hyphens to separate words (not underscores), keep names descriptive but concise, and include relevant keywords naturally. Google's image SEO documentation explicitly states that the file name is used as a signal for understanding image content.

    Alt Text

    Alt text is the single most important image SEO element. It describes the image for screen readers (accessibility) and search engines. Every informational image on your site needs meaningful alt text. For a deep dive on writing effective alt text, see our guide on how to fix missing alt text on images.

  • Bad: alt="" or alt="image" or alt="photo"
  • Good: alt="Cracked iPhone 15 screen before professional repair at MobileBarn"
  • Over-optimized: alt="iPhone screen repair cheap iPhone repair Sydney best iPhone repair service"
  • Write alt text that describes what the image shows, naturally include relevant keywords when appropriate, and keep it under 125 characters. Don't keyword-stuff — Google penalizes it, and it creates a terrible experience for screen reader users.

    Check your site for missing alt text with Clarity SEO's free audit:

    → Check your alt text now

    Title Attributes and Captions

    The title attribute shows a tooltip on hover. It's less important for SEO than alt text but can provide additional context. Captions (text displayed below an image) are read more often than body copy — studies show users scan captions even when they skip the surrounding text. Use captions strategically to reinforce key points and include relevant keywords naturally.

    Surrounding Context

    Google uses the text surrounding an image to understand its content. Place images near relevant text, use descriptive headings above image sections, and ensure the page topic aligns with the image content. An image of a product works best on the product page, not a random blog post.

    Image Sitemaps

    An image sitemap helps Google discover images that might not be found through normal crawling — particularly images loaded via JavaScript, CSS background images, or lazy-loaded content. You can either add image entries to your existing XML sitemap or create a separate image sitemap:

    <url> <loc>https://example.com/product-page</loc> <image:image> <image:loc>https://example.com/images/product-photo.webp</image:loc> <image:title>Product name and description</image:title> </image:image> </url>

    This is especially valuable for e-commerce sites with hundreds or thousands of product images. Submit your image sitemap through Google Search Console for fastest discovery.

    Measuring Image Performance with Lighthouse

    Google Lighthouse (built into Chrome DevTools) is the best free tool for measuring image optimization. Run a Lighthouse audit on any page and look for these image-specific diagnostics:

  • "Serve images in next-gen formats": Flags images that could be converted to WebP or AVIF for smaller file sizes.
  • "Properly size images": Identifies images that are significantly larger than their display size — e.g., serving a 3000px image in a 300px container.
  • "Efficiently encode images": Finds images that could benefit from better compression settings.
  • "Defer offscreen images": Identifies images below the fold that aren't lazy-loaded.
  • "Image elements do not have explicit width and height": Flags images missing dimension attributes that cause layout shift.
  • You can also check your page's overall speed and image performance with Clarity SEO's speed checker:

    → Test your website speed

    For a comprehensive understanding of how speed metrics affect your overall SEO health, check out our guide on how to improve your website speed for SEO.

    Image Optimization Checklist

    Use this checklist for every image you add to your website:

  • ✅ Correct format chosen (WebP for most, AVIF with fallback for maximum savings, SVG for vectors)
  • ✅ Compressed before upload (60–80% reduction is typical for lossy)
  • ✅ Resized to actual display dimensions (don't serve 4000px images in 800px containers)
  • ✅ Descriptive file name with hyphens (not IMG_12345.jpg)
  • ✅ Meaningful alt text that describes the image (under 125 characters)
  • ✅ Width and height attributes set to prevent layout shift
  • ✅ Lazy loading on below-the-fold images (loading="lazy")
  • ✅ LCP image has fetchpriority="high" and is NOT lazy-loaded
  • ✅ Responsive srcset and sizes for images displayed at varying widths
  • ✅ Images served via CDN (not just your origin server)
  • FAQ

    What is the best image format for SEO?

    WebP is the best all-around image format for SEO in 2026. It produces files 25–35% smaller than JPEG at equivalent quality, supports transparency, and has over 97% browser support. For maximum optimization, use AVIF with WebP and JPEG fallbacks via the <picture> element. The actual format matters less to Google's ranking algorithm than the resulting page speed — what matters is that your images are small, fast-loading, and have proper alt text.

    How much does image optimization improve page speed?

    According to the HTTP Archive, images account for nearly 50% of the average web page's total weight. Properly optimizing images — using modern formats, compression, responsive sizing, and lazy loading — can reduce total page weight by 50–80%. For a typical page with 2MB of images, optimization might bring that down to 400–600KB, cutting load times by several seconds on mobile connections.

    Should I lazy load all images?

    No. Lazy load images that are below the fold (not visible when the page first loads), but do NOT lazy load above-the-fold images — especially your LCP (Largest Contentful Paint) image. Lazy loading your hero image or main product photo actually hurts performance because it adds a delay before the browser starts downloading it. Set fetchpriority="high" on your LCP image and loading="lazy" on everything else.

    Does alt text affect SEO rankings?

    Yes. Alt text is the primary way Google understands what an image shows, and it directly affects image search rankings. It's also a minor on-page SEO signal for the page itself. Google's image SEO best practices explicitly state that alt text helps Google understand the subject matter of images. Beyond SEO, alt text is required for web accessibility — it's what screen readers use to describe images to visually impaired users.

    What is the ideal image file size for the web?

    There's no single ideal size, but as a guideline: hero/banner images should be under 200KB, product/content images under 100KB, and thumbnails under 30KB. A well-optimized WebP hero image at 1600px wide can typically achieve 80–150KB at excellent quality. If any single image on your page exceeds 500KB, it's almost certainly not optimized. Use Lighthouse or Clarity SEO's speed checker to identify oversized images on your site.

    How do I convert images to WebP or AVIF?

    Use Squoosh (squoosh.app) for individual images with visual quality comparison. For batch conversion, use command-line tools like cwebp (for WebP) or avifenc (for AVIF). WordPress users can install ShortPixel or Imagify to convert automatically on upload. Build systems like Next.js's Image component handle conversion automatically at request time. For CDN-based conversion, Cloudinary and Cloudflare Images can transform formats on the fly.

    Related Guides

    Image optimization is one part of a fast, well-optimized website. Explore these related guides:

  • How to Fix Missing Alt Text on Images — A deep dive into writing effective alt text for accessibility and SEO.
  • How to Improve Your Website Speed for SEO — Comprehensive speed optimization beyond just images.
  • What Are Core Web Vitals and How to Improve Them — Understand LCP, CLS, and INP metrics that images directly impact.
  • How to Make Your Website Mobile-Friendly — Mobile image optimization is crucial for the majority of web traffic.
  • What Is a Good SEO Score? — See how image optimization factors into your overall SEO health score.
  • Summary

    Image optimization is the single highest-impact performance improvement you can make to most websites. Use WebP or AVIF for modern compression, compress every image before upload, implement responsive srcset for different screen sizes, lazy load below-the-fold images, serve through a CDN, and never forget descriptive file names and alt text. These techniques can cut your page weight in half and dramatically improve your Core Web Vitals scores — directly translating to better rankings and more organic traffic.

    Find out how your images are performing with a free Clarity SEO audit.

    → Get your free SEO Report Card

    Related Tools