You upload a beautiful photo straight from your camera or smartphone – and suddenly the website loads noticeably slower. According to the Web Almanac 2025, images and video still make up the largest share of a web page's data. The good news: with a few simple steps they can be shrunk to a fraction of their size without any visible loss of quality. In this article I'll show you how – with real numbers.
Why file size matters
Every kilobyte has to be downloaded by your visitors. That has several consequences:
- Loading time: Large images delay the page from building up, especially on a weak connection. People who have to wait too long are quickly gone again.
- Search engines: Google also takes into account how fast a page loads. In my article on the quality check of your own website I showed how to test this with Lighthouse. Oversized images are among the most common findings there.
- Mobile data: Many people browse on the go with a limited data plan. An unnecessarily large image eats into it.
The right width in pixels
The biggest lever is the pixel size. A current smartphone camera produces photos 4,000 pixels wide and more. On a website, however, an image is rarely displayed wider than 1,200 to 1,600 pixels, and an image within the text often only 700 to 800 pixels.
As a rule of thumb:
- Full-width images: about 1,600 to 2,000 pixels
- Images within the text: about twice the display width, so they stay sharp on high-resolution screens – for a display width of 734 pixels, that's around 1,500 pixels
- Thumbnails and teasers: 400 to 800 pixels
Anything beyond that gets scaled down by the browser anyway – only after it has been downloaded in full.
The right formats
- JPEG: the classic for photos. Supported everywhere and compresses well.
- PNG: lossless and with transparency. Good for graphics with few colours, but far too large for photos.
- WebP: a modern format supported by all current browsers. Considerably smaller than JPEG and PNG at comparable quality.
- AVIF: even newer and usually a little smaller than WebP. Supported by all current browsers, but takes longer to create.
- SVG: not a pixel image but a vector graphic. Ideal for logos, icons and simple illustrations, because it stays sharp at any size and is usually only a few kilobytes.
A test with real numbers
To show how much difference this makes, I ran two images from my own projects through different formats.
Example 1: a photo-heavy screenshot. The screenshot of Andy Besuch's portfolio website, which you can see at the top of this page, is 1,440 × 881 pixels and consists almost entirely of photos. The starting point was the PNG file, just as the screenshot tool saves it.
- as PNG: 1,838 KB
- as JPEG (quality 80): 338 KB
- as WebP (quality 80): 133 KB
- as AVIF (quality 60): 103 KB
- scaled down to 734 pixels wide, as JPEG: 111 KB, as WebP: 46 KB
From the PNG to the scaled-down WebP, the image shrinks to around 2.5 percent of its original size. On a normal screen you can't see any difference.
Example 2: a screenshot with lots of text and flat areas. The screenshot of the Vorgio home page is also 1,440 × 881 pixels.
- as PNG: 391 KB
- as JPEG (quality 80): 151 KB
- as WebP (quality 80): 42 KB
- as AVIF (quality 60): 30 KB
- scaled down to 734 pixels wide, as WebP: 16 KB
Two things stand out: for photos, PNG is by far the worst choice. And WebP and AVIF are considerably smaller than JPEG in both cases. The exact values naturally depend on the subject and the chosen quality level, but the order of magnitude is typical.
Compressing without expert knowledge
You don't need expensive software for any of this:
- Squoosh (squoosh.app) is a free tool in the browser. You drag an image in, choose format, quality and width, and see a direct side-by-side comparison. The images are not uploaded but processed locally in your browser.
- Export dialogs: Most image editors have a function such as "Export" or "Save for Web" where you can set size and quality. On a Mac, even the Preview app will do: "Tools" → "Adjust Size", then choose the quality when exporting.
A quality between 70 and 80 is a good compromise for most photos.
File names and alt texts
Two small things that are often forgotten:
Descriptive file names. IMG_4711.jpg means nothing to anyone. costume-design-theatre-midsummer-nights-dream.jpg, on the other hand, helps search engines understand the image. Use lower case, hyphens instead of spaces, and no special characters.
Alt texts. The alternative text describes what can be seen in the image. Screen readers read it aloud, which makes it indispensable for blind and visually impaired users. Search engines also use it to understand the image content. A good alt text is short and concrete, for example "Board members inspecting the gardens in spring" instead of "Image1". Purely decorative images get an empty alt text.
Lazy loading and responsive images
Two techniques make sure that only what is really needed gets loaded. Usually whoever looks after your website technically, or your CMS, takes care of this, but it's good to know about them:
Lazy loading means that images further down the page are only loaded when you scroll close to them. Modern browsers can do this out of the box; a single attribute in the HTML is enough. Exception: the large image right at the top should load immediately.
Responsive images means that the same image exists in several sizes and formats, and the browser picks the right version itself. The smartphone gets the 800-pixel-wide WebP, the large screen the 1,600-pixel version, and an old browser falls back to JPEG.
Good content management systems generate these variants automatically from the uploaded original. On Andy Besuch's website, which I built with Statamic, the built-in image processing Glide does this: every uploaded photo is turned into WebP versions in several widths between 750 and 1,540 pixels, and the browser only loads the one it needs.
For me, one rule applies here: clients and editors should ideally not have to worry about any of this. A modern CMS or static site generator has to handle it, no matter how large the original file is. The system itself creates the right pixel dimensions and file sizes and builds a <picture> element from them – an HTML building block that offers several versions of the same image, from which the browser picks the right one. The tips in this article still don't hurt. But if someone uploads a 20 MB photo straight from the camera, that must not slow the page down.
For my own static site generator Nera, I wrote the images plugin for exactly this purpose (you'll also find it in the plugin overview on nera.js.org). When the site is built, it automatically turns every image in the text into AVIF and WebP versions in several widths, sets width and height so nothing shifts while loading, loads images further down only when needed, and strips camera data such as GPS coordinates along the way. I tested it on this website in October: the 32 images in the blog added up to 4.2 MB as originals; as AVIF, a smartphone now downloads just 0.45 MB of them.
Conclusion
Preparing images properly is no rocket science: choose a suitable width, use a modern format such as WebP, compress at quality 70 to 80, give the file a sensible name and add an alt text. My test shows that almost 2 MB can quickly become less than 50 KB – without anyone seeing a difference. And a good system takes most of this off your hands anyway.
If your website loads slowly or Lighthouse reports oversized images, let's take a look at it together. As part of maintenance and content care, I also make sure new images go onto the site in the right size from the start.
Yours, Michael Becker