How to Optimize Images for the Web
Images account for nearly half of the average web page's total weight. Unoptimized images slow down load times, hurt your SEO rankings, increase bounce rates, and waste your users' bandwidth. The good news? Image optimization is straightforward once you know what to do.
Why Image Optimization Matters
Google considers page speed a ranking factor, and images are usually the biggest performance bottleneck. Here's what proper image optimization gives you:
- Faster page loads — users expect pages to load in under 3 seconds; optimized images get you there
- Better SEO — Google's Core Web Vitals (LCP, CLS) are directly affected by image loading
- Lower bandwidth costs — smaller files mean less data transfer for you and your users
- Better mobile experience — mobile users on slower connections benefit the most
Step 1: Choose the Right Format
Different image formats serve different purposes. Choosing the right one is the single biggest optimization you can make:
| Format | Best For | Transparency | Size |
|---|---|---|---|
| JPEG | Photos, complex images | No | Small |
| PNG | Screenshots, icons, graphics with text | Yes | Large |
| WebP | Everything (modern replacement for JPEG & PNG) | Yes | 25-35% smaller than JPEG |
| AVIF | Next-gen format, best compression | Yes | 50% smaller than JPEG |
| SVG | Icons, logos, simple illustrations | Yes | Tiny (vector) |
Rule of thumb: Use WebP as your default format for photos and graphics. Fall back to JPEG for photos and PNG for images needing transparency. Use SVG for icons and logos.
Convert Image Formats Instantly
Convert between JPEG, PNG, WebP, and more right in your browser — no upload needed, completely private.
Open Image Format Converter →Step 2: Resize to the Display Size
One of the most common mistakes is serving a 4000×3000 pixel image that displays at 800×600 on screen. The browser downloads the full file but only uses a fraction of the data. Always resize images to match (or be close to) their display dimensions.
Common display widths
- Hero images: 1200-1600px wide (full-width sections)
- Blog post images: 800-1000px wide
- Thumbnails: 300-400px wide
- Icons/avatars: 64-128px wide
For Retina/HiDPI displays, serve images at 2x the display size (e.g., 1600px for an 800px display area).
Step 3: Compress Without Visible Quality Loss
After choosing the right format and size, the final step is compression. Most images can be compressed by 50-80% without any visible quality difference. There are two types of compression:
- Lossy compression — removes some image data permanently. JPEG quality 75-85 is usually indistinguishable from 100 for photos. Best for photos and complex images.
- Lossless compression — reduces file size without losing any data. Best for screenshots, text-heavy images, and PNG files where every pixel matters.
Quick compression guidelines
Compress Images Free
Reduce image file sizes by up to 80% without quality loss — all processing happens in your browser.
Open Image Compressor →Step 4: Implement Responsive Images in HTML
Use the HTML <picture> element and srcset attribute to serve different image sizes to different devices:
<picture>
<source srcset="image.avif" type="image/avif">
<source srcset="image.webp" type="image/webp">
<img src="image.jpg" alt="Description"
loading="lazy" width="800" height="600">
</picture>Always include width and height attributes to prevent layout shift (CLS), and use loading="lazy" for images below the fold.
Image Optimization Checklist
- Choose the right format (WebP for most, JPEG for photos, PNG for transparency)
- Resize to display dimensions (don't serve 4000px images at 800px)
- Compress with quality 75-80 for photos
- Use responsive images with srcset and the picture element
- Add lazy loading for below-the-fold images
- Always set width and height to prevent layout shift
- Use a CDN to serve images from edge locations
- Consider AVIF for maximum compression (check browser support)
Key Takeaways
- Image optimization is the fastest way to improve page load speed and Core Web Vitals.
- Format, size, and compression are the three pillars — get all three right for optimal results.
- WebP offers the best balance of quality and file size for most use cases today.
- Free browser-based tools let you optimize images without installing software or uploading to third-party servers.