Best Image Compression Techniques for Faster Websites (2026)
Images account for an average of 51% of total page weight across the web (HTTP Archive, 2025). No other asset type has as much impact on page load time — and no other optimisation delivers faster, more dramatic results than getting your image compression right. A 2 MB page with unoptimised images can often be reduced to 600 KB with zero visible quality difference using the techniques in this guide.
This is the definitive guide to image compression for websites in 2026: what lossy and lossless mean, which quality settings to use, how to pick the right format for each image type, and which tools automate the entire process.
Lossy vs Lossless Image Compression — What Is the Difference?
All image compression falls into one of two categories. Understanding the difference is essential to making the right trade-off for each image on your site.
Lossy Compression
Lossy compression permanently discards image data to achieve smaller file sizes. The data removed is chosen carefully using algorithms that model human visual perception — specifically, we are less sensitive to high-frequency detail (fine texture) and colour variation than to luminance (brightness) and large-scale structure. Lossy encoders throw away the detail we are least likely to notice.
The result: files that are 5–15% of the original uncompressed size, with no visible quality difference at moderate settings. Every re-encode of a lossy image compounds the loss — which is why you should always keep an original master file.
Lossy formats: JPEG, lossy WebP, lossy AVIF, lossy HEIC.
Lossless Compression
Lossless compression finds patterns in the data and stores them more efficiently, without discarding anything. The decompressed result is identical to the original, pixel-for-pixel. Lossless compression algorithms (LZ77, Huffman coding, DEFLATE) look for repeated sequences and store them as references rather than full data — similar to how a ZIP file works.
The result: files that are 40–70% of the original uncompressed size. Larger than lossy, but no quality loss regardless of how many times you save.
Lossless formats: PNG, lossless WebP, lossless AVIF, TIFF, BMP.
| Property | Lossy | Lossless |
|---|---|---|
| File size | 5–15% of original | 40–70% of original |
| Quality | Slight degradation (usually invisible) | Perfect — identical to original |
| Re-save safe? | No — each re-save degrades further | Yes — unlimited re-saves |
| Best for | Photographs, hero images, product photos | Screenshots, icons, logos, text-heavy images |
| Formats | JPEG, lossy WebP, lossy AVIF | PNG, lossless WebP, TIFF |
The rule of thumb: use lossy compression (WebP or JPEG) for any image with smooth colour gradients and photographic content. Use lossless compression (lossless WebP or PNG) for images with sharp edges, flat colour areas, text, logos, and screenshots.
Technique 1: Use the Right Format
Switch to WebP as Your Default
WebP is the highest-impact single change for most websites. Serve lossy WebP for photographs (quality 80–85), lossless WebP for screenshots and graphics with transparency. Use a <picture> element with a JPEG fallback. This alone resolves Google PageSpeed's "Serve images in next-gen formats" audit.
Add AVIF as a First Choice
AVIF achieves even better compression than WebP and is supported in Chrome, Firefox, and Safari 16+. Serve it as the first source in a <picture> element with WebP and JPEG as fallbacks. Pre-encode AVIF at build time (encoding is slow; decoding is fast). Use quality 60–70 for AVIF — equivalent visual quality to JPEG Q85 but much smaller files.
Never Use PNG for Photographs
PNG is lossless and produces huge files for photographic content. A photo that is 280 KB as WebP might be 1.2 MB as PNG. Use PNG only for images that specifically require lossless compression: screenshots, logos, diagrams, images with text, or images with transparency that would show JPEG artefacts around the alpha edge.
Use SVG for Logos and Icons
Logos, icons, illustrations, and simple diagrams should be SVG (Scalable Vector Graphics) rather than any raster format. An SVG logo that renders perfectly at any size might weigh 2–8 KB; the same logo as a PNG for retina screens might be 50–200 KB. SVGs also render crisply on every screen density without needing @2x or @3x variants.
Technique 2: Get Quality Settings Right
Quality settings determine the compression aggressiveness — how much data is discarded (lossy) or how much effort the encoder expends finding patterns (lossless). Getting these right avoids the two failure modes: files that are unnecessarily large (quality too high) or visibly degraded (quality too low).
| Use case | JPEG quality | WebP quality | Expected file size* |
|---|---|---|---|
| Hero/banner (1200×630) | 80–85 | 78–83 | 150–300 KB |
| Article inline images | 78–83 | 76–81 | 80–180 KB |
| Thumbnails (300×300) | 70–78 | 68–76 | 20–60 KB |
| Product photos (e-commerce) | 82–88 | 80–86 | 100–250 KB |
| Archive / master files | 92–95 | — | Keep as RAW/TIFF |
| Screenshots / UI | — | Lossless | 40–120 KB |
*For typical 12-megapixel photographs. Actual sizes vary by image complexity.
Note that WebP quality values are not directly equivalent to JPEG quality values — WebP Q80 typically produces results comparable to JPEG Q85-90 in visual quality. Start with WebP at 80 and compare visually with your source JPEG.
Technique 3: Serve Correctly Sized Images
Serving a 2000px-wide image in a 400px container wastes 96% of the pixel data. The browser downloads the full-resolution file and then scales it down in CSS. This is one of the most common and most wasteful image mistakes.
The fix is responsive images using the srcset attribute:
<img
srcset="image-400.webp 400w, image-800.webp 800w, image-1200.webp 1200w"
sizes="(max-width:600px) 100vw, (max-width:900px) 80vw, 1200px"
src="image-1200.webp"
alt="Description"
width="1200"
height="630"
loading="lazy"
>
The browser selects the most appropriate resolution based on the device's screen width and pixel density. A mobile user with a 390px screen downloads the 400w variant; a desktop user with a 1440px screen downloads the 1200w variant. Combined with WebP format conversion, responsive images can reduce image payload by 60–70% for mobile users.
Technique 4: Strip Unnecessary Metadata
JPEG files often contain embedded metadata that adds 20–50 KB of file size with no visual benefit:
- EXIF data — camera model, GPS coordinates, shooting settings, timestamps. Important to keep for personal archives; unnecessary on a web server.
- ICC colour profiles — usually
sRGB(3 KB) or a custom camera profile (50+ KB). Strip to a standard sRGB tag or remove entirely. - Thumbnail previews — embedded low-resolution previews used by photo management software. Not needed on the web.
- XMP/IPTC data — editorial metadata from photo agencies. Often 10–30 KB per image.
Most image optimisation plugins (ShortPixel, Imagify) strip metadata automatically. To strip manually: convert input.jpg -strip output.jpg (ImageMagick) or jpegtran -copy none input.jpg output.jpg.
Technique 5: Lazy Loading
Lazy loading defers the download of off-screen images until the user scrolls near them. Adding it requires one HTML attribute:
<img src="image.webp" alt="Description" width="800" height="500" loading="lazy">
All modern browsers support loading="lazy" natively since 2020. The impact on initial page load depends on how many images are below the fold — on a typical blog post with 6 images, 3–4 are usually below the fold. Deferring those reduces the initial download by 40–70% of total image weight.
Critical rule: never add loading="lazy" to your LCP image (the hero/banner). The LCP image is in the viewport on load and should start downloading as early as possible. For the LCP image, add loading="eager" (or omit the attribute, since eager is the default) and add a <link rel="preload"> in the head.
Technique 6: Use a CDN for Image Delivery
Content Delivery Networks (CDNs) cache your images at servers located physically close to your visitors, reducing download latency regardless of file size. For global websites, CDN delivery can reduce image load times by 40–70% for international users compared to serving from a single origin.
Cloudflare (Free)
Free CDN for any website. Images are cached at 300+ global nodes. Cloudflare Images (paid add-on) adds automatic WebP conversion and resizing.
Cloudinary
Image and video CDN with automatic format conversion (WebP, AVIF), resizing, and quality optimization. Free tier: 25 GB storage, 25 GB bandwidth.
Imgix
Real-time image processing CDN. Append ?auto=format to any URL and it serves the best format each browser supports. Paid from $10/month.
Fastly Image Optimizer
Used internally by Shopify and Pinterest. Enterprise-grade CDN with automatic WebP and AVIF delivery. Best for high-traffic sites.
Start with Step 1: Convert JPG to WebP
Our free browser-based converter requires no upload, no registration, and handles multiple files at once. The fastest way to start compressing your images properly.
Best Image Compression Tools in 2026
| Tool | Type | Best for | Cost |
|---|---|---|---|
| Convertlo JPG→WebP | Browser-based | Manual conversion, privacy-sensitive images | Free |
| Squoosh | Browser-based | Quality preview, format comparison | Free |
| ShortPixel | WordPress plugin / API | WordPress sites, automated pipeline | Free 100/mo; paid from $9.99/mo |
| Imagify | WordPress plugin | WordPress + WP Rocket integration | Free 20MB/mo; paid from $4.99/mo |
| cwebp (CLI) | Command-line | Batch conversion, scripts | Free (Google) |
| Sharp (Node.js) | Library | Build pipelines, server-side processing | Free (open source) |
| ImageMagick | Command-line | Any format, full metadata control | Free (open source) |
| Cloudinary | CDN + API | Automatic format/resize in URL params | Free tier; paid from $89/mo |
The Complete Image Optimisation Checklist
Apply these to every image before it goes live on your site:
- Choose the right format — WebP (or AVIF) for photos; lossless WebP or PNG for graphics; SVG for logos/icons
- Set the right quality — 80–85 for WebP/JPEG photos; lossless for screenshots and logos
- Resize to display dimensions — never serve a 2000px image in a 400px container
- Strip metadata — remove EXIF, ICC profiles, thumbnails
- Add explicit width and height — prevents layout shift (CLS)
- Add lazy loading —
loading="lazy"on all below-the-fold images - Preload the LCP image —
<link rel="preload" as="image">in<head> - Serve via CDN — for international visitors and cache efficiency
- Use responsive images —
srcsetandsizesfor multi-resolution delivery - Serve with a JPEG fallback —
<picture>element for older browsers
Applying all ten to a typical blog produces a 60–80% reduction in image payload and brings most sites into the "Good" range for Core Web Vitals LCP on mobile.