Images are usually the heaviest part of a web page. A single photo straight from a phone can weigh 3 to 5 MB, more than all the text, styles and scripts of a typical page combined. Heavy images make pages slow on mobile connections, use up visitors’ data plans, and hurt search rankings through Google’s Core Web Vitals. The good news is that most images can be made five to ten times smaller with no difference anyone will notice. This guide shows how.
Why image weight matters
When someone opens a page, the browser has to download every image they can see before the page looks finished. On a fast office connection a 4 MB hero image might take a fraction of a second; on a 4G connection with weak signal it can take several seconds, and many people leave a page that hasn’t loaded within three seconds.
Google measures this with a metric called Largest Contentful Paint (LCP): the time until the biggest visible element, very often an image, has loaded. Google considers an LCP under 2.5 seconds “good”, and it is one of the signals used in search ranking. Compressing your largest images is usually the single quickest way to improve it.
Step 1: resize before you compress
The most effective optimisation is also the simplest: don’t send more pixels than the screen will show. A typical phone camera produces images around 4000 × 3000 pixels. Most website content areas are 700 to 1200 pixels wide, and even a full-width banner rarely needs more than 2000 to 2400 pixels.
Halving an image’s width and height reduces the pixel count to a quarter, and the file size falls roughly in proportion. So resizing a 4000-pixel photo to 1600 pixels removes about 84% of its pixels before any compression happens.
A sensible rule: take the largest width the image is ever displayed at, and double it to keep it sharp on high-resolution “retina” screens. An image shown 600 pixels wide in a blog post should be saved at about 1200 pixels.
Step 2: choose the right format
- JPG is the universal choice for photographs. It compresses smooth gradients and textures very efficiently but doesn’t support transparency.
- WEBP supports both lossy and lossless compression plus transparency, and is typically 25 to 35% smaller than a JPG of the same visual quality. Every current major browser supports it.
- PNG is lossless, which makes it right for screenshots, logos, diagrams and anything with sharp edges or text. It’s the wrong choice for photos, which become much larger as PNG.
- SVG isn’t a pixel format at all: it describes shapes mathematically. Use it for logos and icons whenever you have a vector original, as it stays sharp at every size and is often tiny.
- AVIF compresses even better than WEBP, but encoding is slow and support in tools is still catching up. It’s worth considering if your website platform generates it automatically.
Step 3: pick a quality setting
Lossy formats like JPG and WEBP let you trade quality for size with a setting from 0 to 100. The relationship is not linear: going from 100 to 85 often halves the file size with no visible change, while going from 60 to 40 saves comparatively little and starts to show blocky artefacts.
| Use | Quality to start with |
|---|---|
| Hero and banner images | 75–80 |
| Photos in articles | 75–85 |
| Product photos that can be zoomed | 85–90 |
| Thumbnails and previews | 60–70 |
Always judge the result at the size it will be displayed, not zoomed in to 400%. Artefacts that are obvious when you zoom are invisible at normal size. Our image compressor shows the size before and after so you can find the lowest setting that still looks right, without uploading your photos anywhere.
Step 4: serve the right size to each screen
A phone with a 400-pixel-wide screen doesn’t need the same image as a 27-inch monitor. HTML lets you offer several sizes and let the browser choose:
<img
src="garden-1200.jpg"
srcset="garden-600.jpg 600w, garden-1200.jpg 1200w, garden-2000.jpg 2000w"
sizes="(max-width: 700px) 100vw, 700px"
width="1200" height="800"
alt="Raised vegetable beds in a sunny garden"
loading="lazy">
srcset lists the available files and their widths, and sizes tells the browser how wide the image will be shown. The browser then downloads only the smallest file that will look sharp. Many content management systems, such as WordPress, generate these sizes for you when you upload a large image, but they work best when the original you upload is already sensibly sized.
Step 5: load images smartly
- Add
loading="lazy"to images further down the page so they only load as the visitor scrolls. Don’t lazy-load the main image at the top of the page; it should load immediately. - Always set
widthandheightattributes. They let the browser reserve space before the image arrives, which stops the page jumping around as it loads. Google measures that jumping too, as Cumulative Layout Shift. - Write useful alt text describing the image. It helps people using screen readers, and helps search engines understand the image.
A quick checklist
- Resize to twice the largest display width.
- Use JPG or WEBP for photos, PNG for screenshots and graphics, SVG for logos.
- Start at 80% quality and lower it while it still looks good at normal size.
- Aim for under 200 KB for most content images and under 300–400 KB for large hero images.
- Offer multiple sizes with
srcset, set width and height, and lazy-load images below the fold.
One last tip: removing metadata comes free with re-encoding. Photos from phones carry EXIF data, including the GPS location where they were taken. Re-saving them through a browser-based compressor strips that information, which saves a few kilobytes and protects your privacy when you publish photos taken at home.