How to Compress Images for the Web Without Losing Quality

Practical techniques to dramatically reduce image file sizes while keeping them looking sharp.

📸 🗜️ ⚡ 🖼️ 🚀

TL;DR: Resize first (2x your display size for retina), pick the right format (AVIF > WebP > JPEG for photos), set quality to 75-85 for JPEG, strip metadata, and lazy-load below-the-fold images. These steps typically cut image payload by 70-90%.

Let me hit you with a number: images account for roughly 40-50% of a typical web page's total weight. That means almost half of what your visitors download is pictures. A single unoptimized photo straight from a camera can be 3-5 MB — and that is often more than your entire web page should weigh.

The good news? Compressing images is the single highest-impact performance win most websites can get. It is not glamorous work, but your users (and Google) will absolutely notice the difference.

Unoptimized images on a website are like bringing a suitcase full of bricks on vacation. Sure, it works technically, but why would you do that to yourself?

Why You Should Care About Image Size

🐌 A 5MB hero image on a 3G connection = 15+ seconds of staring at nothing

Lossy vs. Lossless: The Two Philosophies

Lossless Compression

Think of it like a ZIP file for images. The file gets smaller, but when you decompress it, you get the exact same pixels back. Typical savings: 10-30%. Formats: PNG (optimized), WebP lossless, AVIF lossless.

Lossy Compression

This one permanently tosses out image data that your eyes probably would not notice anyway. The savings are much bigger: 60-90%. Formats: JPEG, WebP lossy, AVIF lossy.

For photographs on the web, lossy compression at the right quality setting is almost always the way to go. The difference between quality 85 and quality 100 is invisible to human eyes but massive in file size.

Picking the Right Format

Format Best For Transparency
JPEGPhotos, complex imagesNo
PNGScreenshots, logos, transparencyYes
WebPEverything (25-35% smaller than JPEG)Yes
AVIFEverything (50% smaller than JPEG!)Yes
SVGIcons, logos, illustrations (vector)Yes

The gold standard today is serving AVIF with a WebP fallback and JPEG as the safety net:

<picture>
  <source srcset="photo.avif" type="image/avif">
  <source srcset="photo.webp" type="image/webp">
  <img src="photo.jpg" alt="Description" loading="lazy">
</picture>

The <picture> element is like a restaurant menu — the browser picks the first format it supports and ignores the rest. Newer browsers get the smaller file automatically.

Quality Settings: The Sweet Spot

The Step Most People Skip: Resize First!

This is the biggest bang-for-your-buck optimization and people skip it constantly. A 4000x3000 pixel photo displayed in an 800px-wide column is wasting 80% of its pixels. Nobody benefits from those extra pixels. Nobody.

📐 Rule of thumb: export at 2x your display width for retina, never more

If your layout column is 800px wide, export the image at 1600px (2x for retina) and call it done. For responsive images, use srcset:

<img
  srcset="photo-800.jpg 800w,
          photo-1200.jpg 1200w,
          photo-1600.jpg 1600w"
  sizes="(max-width: 800px) 100vw, 800px"
  src="photo-1200.jpg"
  alt="Description"
  loading="lazy"
>

File Size Targets to Aim For

Bonus Optimizations

Never lazy-load your hero image or anything above the fold. That is like telling your front door guests to wait outside while you finish decorating. They will leave.

The Compression Workflow Checklist

  1. Resize to max display dimensions (2x for retina).
  2. Pick the right format (AVIF > WebP > JPEG for photos; SVG > PNG for graphics).
  3. Set quality to the lowest value that still looks good (start at 80, lower until you see artifacts, bump back up).
  4. Strip metadata unless you specifically need it.
  5. Use responsive images with srcset for different screen sizes.
  6. Lazy-load everything below the fold.

Follow these steps and you will typically cut your total image payload by 70-90%. Your pages load faster, your users are happier, your Google ranking improves, and your hosting bill goes down. It is one of those rare wins where everybody benefits.

Try It Yourself

Drop your images into our browser-based compressor. No upload to any server — everything runs locally in your browser.

Open Image Compressor →