Tutorials

Image Optimization Best Practices for Web Performance

Emma Rodriguez
Emma Rodriguez November 18, 2025
4 min read 604 views
Image Optimization Best Practices for Web Performance

Images account for more bytes on average than any other content type on the web, often comprising 50-80% of a webpage's total size. Image optimization is one of the most effective ways to improve your site's performance and Core Web Vitals scores. Properly optimized images load faster, consume less bandwidth, and provide a better user experience across all devices.

1. Choose the Right Image Format

Selecting the appropriate image format is crucial for optimal performance. Modern formats offer significantly better compression than traditional formats.

  • WebP: 25-35% smaller than JPEG, supports transparency and animation (95% browser support)
  • AVIF: 50% smaller than JPEG with better quality, newer format (85% browser support)
  • JPEG: Best for photographs with fallback support
  • PNG: Best for graphics with transparency, logos, and simple illustrations
  • SVG: Perfect for icons and logos (scalable without quality loss)

Use the <picture> element to serve modern formats with fallbacks:

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

2. Resize Images to Display Dimensions

Never serve an image that is larger than its maximum display size. A 3000x2000px image displayed at 300x200px wastes bandwidth and processing power. Always resize images to match their largest display dimensions across all breakpoints.

  • Mobile: typically 320-768px wide
  • Tablet: typically 768-1024px wide
  • Desktop: typically 1024-1920px wide
  • Retina displays: serve 2x images for crisp rendering

3. Compress Images Effectively

Compression reduces file size by removing unnecessary data. Choose between lossy and lossless compression based on your needs.

Lossy Compression

Reduces file size by 60-80% with minimal visible quality loss. Best for photographs and complex images.

  • TinyPNG/TinyJPG: Web-based compression with excellent quality
  • Squoosh: Google's image optimizer with real-time preview
  • ImageOptim: Mac app for batch optimization
  • Sharp (Node.js): High-performance image processing library

Lossless Compression

Removes metadata and optimizes encoding without quality loss. Reduces file size by 10-30%.

4. Implement Lazy Loading

Lazy loading defers loading of offscreen images until users scroll near them, reducing initial page load time by 30-50%.

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

The native loading="lazy" attribute is now supported by 95% of browsers. For critical above-the-fold images, use loading="eager" or omit the attribute.

5. Use Responsive Images with srcset

Serve appropriately sized images for different device widths using the srcset attribute.

<img 
  srcset="small.jpg 320w, medium.jpg 768w, large.jpg 1200w"
  sizes="(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 33vw"
  src="medium.jpg" 
  alt="Responsive image">

6. Set Explicit Dimensions

Always specify width and height attributes to prevent layout shifts and improve CLS scores.

<img src="image.jpg" width="800" height="600" alt="Description">

Modern browsers use aspect ratio calculation, so the image will still scale responsively with CSS.

7. Optimize Image Delivery

  • Use a CDN: Distribute images globally for faster delivery
  • Enable caching: Set long cache expiration headers
  • Implement WebP fallback: Serve WebP to supported browsers
  • Use image CDNs: Services like Cloudinary or Imgix optimize automatically

Frequently Asked Questions

What is the ideal image size for web?

Aim for under 100KB per image for optimal performance. Hero images can be up to 200KB, but most images should be 50-100KB after optimization.

Should I use WebP or AVIF?

Use both with fallback to JPEG. Serve AVIF to supported browsers (50% smaller), WebP as fallback (25% smaller), and JPEG for maximum compatibility.

How does image optimization affect SEO?

Optimized images improve page speed, which is a Google ranking factor. They also improve Core Web Vitals scores (especially LCP) and reduce bounce rates.

Image Optimization Tools & Resources

  • Squoosh: https://squoosh.app - Free image optimizer from Google
  • TinyPNG: https://tinypng.com - Popular lossy compression
  • ImageOptim: https://imageoptim.com - Mac batch optimizer
  • Sharp: https://sharp.pixelplumbing.com - Node.js image processing
  • Ubmetrics: Test your image optimization impact on performance

Conclusion

Image optimization is essential for modern web performance. By implementing these best practices—choosing the right formats, compressing effectively, using lazy loading, and serving responsive images—you can reduce your page size by 50-80% and dramatically improve load times. Start optimizing your images today and use Ubmetrics to measure the performance improvements.

Tags

Share this article