Skip to content

How to optimize images for your website without losing quality

On most websites, images make up the largest share of a page's weight. That is also where the easiest wins are: a page that goes from 4 MB to 2 MB loads faster, uses less mobile data and emits less CO2. Here is the method, step by step.

1. Resize the image to its display size

This is the most important step, and the one most often skipped. If an image is shown in an 800-pixel-wide frame, there's no point sending a 4,000-pixel file. For high-resolution screens, plan for about twice the displayed size, no more.

A full-width banner rarely needs to go beyond 1,920 pixels. Past that, visitors download detail they will never see.

2. Pick the right format: WebP rather than JPEG or PNG

WebP is a format Google designed for the web. According to its own tests, a WebP file is on average 25 to 34% smaller than a JPEG of similar quality, and about 26% smaller than a PNG in lossless mode. It supports transparency, and every current browser can display it.

AVIF compresses even better, but it is slower to produce and still poorly supported by some tools. For most sites, WebP is the best trade-off today.

Keep SVG for logos and icons: it's a vector format, already very light, and shouldn't be converted.

3. Set the compression quality

Lossy compression removes information the eye barely notices. A quality setting around 80 out of 100 usually gives very good results for photos: you cannot tell the difference at normal size, but the file is much lighter.

Going below 70 brings out artifacts on gradients and faces. For screenshots with text, stay closer to 85 or 90.

4. Load images at the right time

An image at the bottom of the page does not need to download until the visitor scrolls there. The loading="lazy" attribute tells the browser to wait until the image gets close to the screen.

On the other hand, the main image visible on arrival should load right away: it often sets the LCP, one of Google's Core Web Vitals.

5. Declare image dimensions in your code

Add width and height attributes to your img tags. The browser then reserves the right space before the image arrives, and the text doesn't jump around while the page loads. That is what CLS measures, another Core Web Vitals metric.

Tools to compress your images

Depending on how many images you have and how technical you are, there are several options:

  • online tools such as Squoosh, handy for a few images at a time;
  • WordPress image optimization plugins, which process new uploads automatically;
  • photo editors (Photoshop, GIMP, Affinity) with their export for web feature;
  • our Quick Fix, which collects the images of a page, converts them to WebP and delivers them ready to swap in, along with a lazy-loading script and cache configuration.

Whatever you use, check the result: an image that is already well optimized sometimes gains almost nothing from being compressed again. Our free audit shows you the possible saving on your page's images before you pay anything.

How heavy are your website's images?

The free audit measures your page weight and estimates how much you could save by optimizing its images.

Test my site for free