Compressing Website Images: WebP, AVIF and the Right Sizes
How to compress images for a website slowed by phone photos: choose WebP or AVIF, resize, set quality, use responsive images and lazy loading with free tools.

Slow websites often share one cause: photos uploaded straight from a phone. A single photo can weigh 4–8 MB while showing up small on screen. If your page has a dozen of those, visitors on mobile data wait, then leave. Here is how to compress images for a website step by step, with free tools for each stage.
Images are the heaviest part of a page
On most small-business websites, images make up the biggest share of a page's total size. Text and code are usually a few hundred KB, while images can reach megabytes. If you only have time for one speed fix, fix the images first.
You have three levers:
- Format: the type of file you use.
- Dimensions: width and height in pixels.
- Quality: how aggressive the compression is.
Choosing a format: JPG, PNG, WebP or AVIF
- JPG: good for photos and supported everywhere. No transparency.
- PNG: good for logos, icons and images with transparent backgrounds. For photos it is usually too large.
- WebP: a modern format that typically produces smaller files than JPG at similar visual quality. Supported by nearly all browsers in use today.
- AVIF: often smaller still than WebP, but slower to encode, and support in some older software is limited. Check a browser-support reference such as MDN before relying on it as your only format.
A safe rule of thumb:
- Photos: WebP as the main choice. Add AVIF if your tool or CMS can generate it automatically.
- Logos and flat illustrations: SVG when available, otherwise PNG or WebP.
- Fallback: keep a JPG for the rare browser or app that does not understand the newer formats.
Many modern CMSs and plugins create WebP versions automatically when you upload. If your site uses one, check its settings before doing the work by hand.
Step 1: resize to the display size
This is the step with the biggest impact. Phone photos are usually 3000–4000 pixels wide. If the image shows at 800 pixels on the page, the rest is wasted.
Common width guidelines:
- Full-width hero image: around 1600–2000 pixels.
- Images inside articles: 800–1200 pixels.
- Thumbnails in product lists or cards: 400–600 pixels.
- Avatars and small icons: 100–200 pixels.
For high-density screens, prepare a version about twice the display width, but do not overdo it. Uploading 4000 pixels for a 400-pixel box helps nobody.
Free tools for resizing: the Photos app on Windows, Preview on Mac, Squoosh (in the browser), or IrfanView for many files at once.
Step 2: set compression and quality
Compression for photos is lossy: some detail is discarded in ways you barely notice. Starting points that often work well:
- JPG and WebP: quality around 70–80.
- AVIF: quality around 50–65 (the scale differs, so test and compare).
Do not trust numbers alone. Open the result and inspect the tricky parts: hair, small text, sky gradients. Lower the quality bit by bit until you start to see a difference, then step back up one notch.
Free tools I recommend:
- Squoosh: side-by-side before and after, supports WebP and AVIF, runs in the browser.
- XnConvert or ImageMagick: for batch conversion.
- CMS compression plugins: to optimise images that are already uploaded.
For logos and PNGs with limited colours, a palette-reduction tool can cut the size without visibly changing the look.
Step 3: responsive images
Different devices need different sizes. A phone does not need to download a 2000-pixel-wide image. In HTML, the srcset and sizes attributes let the browser pick the best version:
<img src="photo-800.webp"
srcset="photo-400.webp 400w, photo-800.webp 800w, photo-1600.webp 1600w"
sizes="(max-width: 600px) 100vw, 800px"
width="800" height="533" alt="Short description of the image">
If you want to offer several formats, use the <picture> element with an AVIF source first, then WebP, then JPG as the fallback.
An important note: always set width and height. That lets the browser reserve space before the image loads, so the layout does not jump around as the page opens.
If you use a CMS, many themes and plugins already generate srcset for you. Make sure that feature is switched on.
Step 4: lazy loading
Images that are not yet on screen do not need to load right away. Add loading="lazy" to images below the fold:
<img src="photo.webp" loading="lazy" width="800" height="533" alt="...">
One exception: do not lazy-load the main image at the top of the page. It should load immediately, because it is usually the biggest element visitors see.
What about background images and banners?
Images set through CSS as backgrounds are often forgotten, yet they tend to be large. Treat them like any other image: resize, compress and use WebP. For rotating banners (sliders), consider whether two or three images are enough. Every extra slide is a download that visitors may never see.
File names and alt text
While you are tidying up, fix two small things:
- Descriptive file names such as
palm-sugar-iced-coffee.webp, notIMG_20260312_0001.webp. - Alt text that briefly describes the image, useful for accessibility and image search.
A simple workflow you can copy
- Copy photos from your phone into one "raw" folder.
- Resize for the purpose (hero, article, thumbnail).
- Convert to WebP at quality 75 as a starting point.
- Check the result visually, then compare file sizes before and after.
- Upload with a clear file name and alt text.
- Test the page with a tool such as PageSpeed Insights or Lighthouse to see the improvement.
Common mistakes
- Uploading the original and just shrinking it with CSS. The file stays heavy.
- Compressing the same file repeatedly, so quality keeps degrading. Always compress from the original.
- Using PNG for photos.
- Lazy-loading the main hero image.
- Forgetting to keep the originals as an archive.
A realistic target for most small-business sites: article images under roughly 150–200 KB and hero images under about 300 KB, as long as they still look sharp. These numbers are guidance, not hard rules, so adjust them to your needs.
Start with your five most visited pages. Fix the images, measure again, and you will see the difference right away.
Read next
NEW
AdSense Rejected? Common Reasons and How to Fix Them
AdSense rejected for low value content, site down or navigation? What each reason means, how to fix it, and when to apply again.
Read more
NEW
Landing Page vs Company Profile vs Online Store: Which Do You Need?
Landing page, company profile or online store? How they differ, when each fits, and five questions to pick the right kind of website.
Read more
NEW
GA4 and Google Tag Manager Setup for Small Businesses: Full Guide
Set up GA4 and Google Tag Manager on a small business site: create the property, add the container, track WhatsApp clicks and forms as key events.
Read more