100% Private

Web Image Optimization Guide: Formats, Compression & Best Practices

Images account for 50% of average webpage weight. Learn how to reduce image file sizes by up to 70% while maintaining visual quality, improving page speed, and boosting SEO rankings.

Why Image Optimization Matters

53%

of mobile users abandon sites that take over 3 seconds to load

50%

of page weight is typically images

7%

conversion rate drop per second of load time

Impact on Core Web Vitals

  • LCP (Largest Contentful Paint): Hero images often determine this metric
  • CLS (Cumulative Layout Shift): Unsized images cause layout shifts
  • Page weight: Directly affects bandwidth and load time

Choosing the Right Format

FormatBest ForTransparencyCompression
JPEGPhotos, complex imagesNoLossy
PNGGraphics, logos, screenshotsYes (alpha)Lossless
WebPEverything (modern browsers)Yes (alpha)Both
AVIFHigh compression needsYes (alpha)Lossy
SVGIcons, logos, illustrationsYesVector (scalable)

Format Selection Flowchart

Is it a photo or complex image?
├── YES → Use WebP (fallback: JPEG)
└── NO → Is it an icon or simple graphic?
├── YES → Use SVG
└── NO → Does it need transparency?
├── YES → Use WebP (fallback: PNG)
└── NO → Use WebP (fallback: JPEG)

WebP: The Modern Default

WebP should be your go-to format for most images:

  • 25-35% smaller than JPEG at equivalent quality
  • 26% smaller than PNG with transparency
  • 97% browser support (all modern browsers)

Lossy vs Lossless Compression

Lossy Compression

Permanently removes image data to reduce file size.

  • 70-90% file size reduction
  • Quality loss (often imperceptible)
  • Best for photos
  • Cannot recover original quality
Lossless Compression

Reduces file size without losing any data.

  • 10-50% file size reduction
  • No quality loss
  • Best for graphics, text
  • Original quality preserved

Quality Settings Guide

JPEG Quality Recommendations:
├── 85-90: High quality (portfolios, hero images)
├── 75-85: Good quality (most website images)
├── 60-75: Medium quality (thumbnails, backgrounds)
└── 40-60: Low quality (placeholders)

WebP Quality Recommendations: ├── 80-90: High quality ├── 70-80: Good quality (recommended default) └── 50-70: Medium quality

Responsive Images

Serve appropriately sized images for each device to avoid sending oversized files to mobile users.

Using srcset and sizes

<img
src="image-800.jpg"
srcset="
image-400.jpg 400w,
image-800.jpg 800w,
image-1200.jpg 1200w,
image-1600.jpg 1600w"
sizes="(max-width: 600px) 100vw,
(max-width: 1200px) 50vw,
800px"
alt="Responsive image example"
>

Art Direction with Picture

<picture>
<!-- AVIF for modern browsers -->
<source type="image/avif" srcset="image.avif">

<!-- WebP fallback --> <source type="image/webp" srcset="image.webp">

<!-- JPEG fallback --> <img src="image.jpg" alt="Description"> </picture>

Common Breakpoints

  • 320px: Small phones
  • 640px: Large phones
  • 1024px: Tablets
  • 1920px: Desktop
  • 2560px: Large/Retina displays

Lazy Loading

Defer loading of off-screen images until users scroll near them.

Native Lazy Loading

<img src="image.jpg" loading="lazy" alt="Description">

Important: Don't lazy load above-the-fold images (LCP candidates).

Best Practices

  • Always set width and height to prevent layout shift
  • Use loading="eager" for critical above-fold images
  • Consider using blur-up placeholders for better UX

<!-- Proper image with dimensions -->
<img
src="photo.jpg"
width="800"
height="600"
loading="lazy"
decoding="async"
alt="Photo description"
>

Optimization Tools

Online Tools

Command-Line Tools

# ImageMagick - Resize and compress
convert input.jpg -resize 1200x -quality 80 output.jpg

# cwebp - Convert to WebP cwebp -q 80 input.png -o output.webp

# SVGO - Optimize SVG svgo input.svg -o output.svg

# Sharp (Node.js) - Batch processing sharp input.jpg --resize 800 --webp --out output.webp

Build Tool Plugins

  • Webpack: image-minimizer-webpack-plugin
  • Vite: vite-plugin-image-optimizer
  • Next.js: Built-in next/image component
  • Gatsby: gatsby-plugin-image

Image Optimization Checklist

Before Publishing

Related Tools

Privacy Notice: This site works entirely in your browser. We don't collect or store your data. Optional analytics help us improve the site. You can deny without affecting functionality.