Images are typically the largest assets on a web page, often accounting for 60-80% of total page weight. Optimising them is the single most impactful thing you can do for page load speed, which directly affects user experience, bounce rate, and search rankings.
Right-Size Your Images
The most common mistake is serving images that are much larger than needed. A 4000×3000 pixel photo (12 megapixels) served at 400×300 display size is 100x larger than necessary. Always resize images to the maximum display dimensions before uploading.
Calculate the maximum size you need: display width × 2 for Retina displays. If an image displays at 800px wide, serve a 1600px wide image. Don't serve larger than necessary.
Choose the Right Compression
For each image, find the compression level where quality loss becomes noticeable, then back off slightly. The sweet spot is usually:
- JPEG: Quality 75-85 (below 70, artefacts become visible)
- WebP: Quality 75-85 (similar to JPEG but smaller files)
- AVIF: Quality 60-70 (AVIF needs lower quality numbers for equivalent visual quality)
- PNG: Use lossless, but only for graphics that need it
Lazy Loading
Images below the fold don't need to load immediately. Add loading="lazy" to defer their loading until the user scrolls near them:
<img src="hero.jpg" alt="Above the fold">
<img src="photo2.jpg" alt="Below the fold" loading="lazy">
<img src="photo3.jpg" alt="Further down" loading="lazy">
This is supported by all modern browsers and can reduce initial page load by 30-50% on image-heavy pages. For the hero image (above the fold), don't use lazy loading — load it immediately.
Responsive Images with srcset
Serve different image sizes for different screen widths. A mobile user doesn't need a 1920px wide hero image on their 375px screen:
<img srcset="photo-640.jpg 640w,
photo-960.jpg 960w,
photo-1280.jpg 1280w,
photo-1920.jpg 1920w"
sizes="(max-width: 768px) 100vw, 50vw"
src="photo-960.jpg"
alt="Responsive photo">
The browser automatically downloads the most appropriate size based on the device's screen width and the sizes attribute. This can save hundreds of kilobytes on mobile devices.
Use CDN Image Optimisation
CDNs like Cloudflare, Cloudinary, and Imgix can automatically:
- Convert images to WebP or AVIF based on browser support
- Resize images on-the-fly for different screen sizes
- Compress images with optimal quality settings
- Serve cached versions from edge locations worldwide
If you're using Cloudflare (as this site does), image resizing is available on Pro plans and above. For free plans, optimise images locally before uploading.
Background Images
CSS background images can't use srcset or loading="lazy". For responsive backgrounds, use the image-set() function:
.hero {
background-image: image-set(
url("hero-640.webp") 1x,
url("hero-1280.webp") 2x
);
}
Measuring Image Performance
Use these tools to identify image optimisation opportunities:
- Google PageSpeed Insights: Reports images that could be compressed further
- Lighthouse (in Chrome DevTools): Detailed audit of image usage
- WebPageTest.org: Shows a waterfall of image loading and identifies slow images
- Chrome DevTools Network tab: See the actual size of each image as transferred
Quick Wins Checklist
- Resize images to maximum display dimensions × 2 before uploading
- Convert to WebP or AVIF for modern browsers (with JPEG/PNG fallback)
- Add
loading="lazy"to below-the-fold images - Use
srcsetfor responsive images - Set explicit width and height attributes to prevent layout shift
- Serve images from a CDN with edge caching
- Avoid serving images larger than 200KB whenever possible
The image tool on this site lets you resize, crop, compress, and convert images — all in your browser. Upload an image, adjust settings, and download the optimised result. No images leave your device, making it safe for personal or confidential photos.