SEO & Performance ·
Image optimisation: WebP, AVIF and sizing images for fast pages
How to optimise images for a fast website: choosing WebP or AVIF, serving the right size to each screen, lazy loading safely and writing alt text that helps search.
By Kareem Mohamed, Web Developer at Digital House
Image optimisation is usually the biggest single speed fix on a business website, and the one most often skipped. Photos are what make a website feel premium, and they are also what make it heavy. This article covers the formats to use, how to serve the right size to each screen, when to lazy-load, and how to write alt text that helps both visitors and search.
Why images slow most business websites down
On the sites I am asked to speed up, the hero is often a photo exported straight from a camera or a design tool: thousands of pixels wide, saved as a large JPEG or PNG, and shrunk by the browser to fit a phone screen. The visitor downloads the whole file and sees a fraction of it.
That one image is frequently the Largest Contentful Paint element, the moment Google uses to judge how quickly your page loaded. So a heavy hero costs you twice: in the visitor's patience and in your Core Web Vitals.
- Files far larger than the size at which they display.
- Old formats, especially PNG used for photographs.
- Every image loading at once, including those at the bottom of a long page.
- No dimensions in the markup, so the layout jumps as images arrive.
- Logos and icons saved as large PNGs instead of small SVG files.
WebP or AVIF: which format should you use?
Both are modern formats supported by all current major browsers, and both produce much smaller files than JPEG at similar visual quality. The differences are practical.
- AVIF usually compresses photographs smaller than WebP, especially large, detailed ones. It is slower to encode, so generating it takes longer at upload or build time.
- WebP is very widely supported, quick to encode and a safe default. It handles transparency, so it can replace most PNGs.
- JPEG remains the fallback for very old browsers and for places that only accept it, such as some email clients.
- SVG is the right choice for logos and icons: sharp at any size and usually tiny.
My default is to generate both AVIF and WebP and let the browser choose. On Beyond Home, a luxury interiors brand where the photography sells the work, every photo ships as AVIF with WebP alongside, so images can stay large and detailed without the pages becoming slow.

Serving the right size to every screen
A phone does not need the same file as a large desktop monitor. Responsive images let you offer several widths and let the browser pick the smallest one that will still look sharp on that screen.
<picture>
<source type="image/avif"
srcset="/img/showroom-640.avif 640w, /img/showroom-1280.avif 1280w, /img/showroom-1920.avif 1920w"
sizes="(max-width: 768px) 100vw, 50vw">
<source type="image/webp"
srcset="/img/showroom-640.webp 640w, /img/showroom-1280.webp 1280w, /img/showroom-1920.webp 1920w"
sizes="(max-width: 768px) 100vw, 50vw">
<img src="/img/showroom-1280.jpg"
alt="Living room with a cream sofa and oak coffee table"
width="1280" height="853" fetchpriority="high">
</picture>
Three parts of that markup matter. srcset lists the available widths, sizes tells the browser how wide the image will display, and width and height let it reserve the space before the file arrives, which stops the layout shifting.
- Export the largest version at about twice the widest display size, not the camera original.
- Generate three or four widths automatically at upload or build time. Nobody should be resizing by hand.
- Compress by eye: lower the quality until you notice a difference, then step back one notch.
Wherever possible, automate all of this. On a custom site, conversion and resizing belong in the upload step, so editors upload one good photo and the site produces every format and width. On WordPress, an image optimisation plugin or an image CDN can do the same job; check that it serves the modern format to browsers that accept it and keeps a fallback for those that do not.
Lazy loading: helpful below the fold, harmful above it
Lazy loading means the browser waits to download an image until the visitor scrolls near it. With the loading="lazy" attribute it is built into browsers, and on a long page it saves a lot of data.
The mistake is applying it to everything. A lazy-loaded hero tells the browser to delay the very image that defines how fast your page feels. The rule I follow:
- Images in the first screen: no lazy loading, and
fetchpriority="high"on the main one. - Everything below:
loading="lazy"anddecoding="async". - Carousels: load the first slide normally and lazy-load the rest.
- Hero backgrounds set in CSS: avoid them, because the browser discovers them late.
Lazy loading also changes what screenshot tools and some crawlers capture, since they only see what has loaded. I ran into this while capturing fifty sites for this portfolio, and wrote about it in screenshots that wait.
Alt text and file names that help search
Alt text is the short description read aloud by screen readers and shown if an image fails to load. Google also uses it, together with the surrounding text, to understand what an image shows, which matters for image search and for the page as a whole.
- Describe what is in the image, in the page's language: 'majlis seating in a villa living room', not 'image1' or a string of keywords.
- Leave the alt empty (
alt="") on purely decorative images, so screen readers skip them. - Give files readable names, such as
oak-flooring-living-room.webp, before uploading. - On bilingual sites, write Arabic alt text for the Arabic page instead of reusing the English.
Good alt text is also part of website accessibility, which helps more people use the site at all.
The best image on a page looks sharp, arrives early and costs the visitor almost nothing to download.
A quick image check you can run today
- Run your homepage through PageSpeed Insights and read the image suggestions in the diagnostics.
- Open the hero image in a new tab and compare its pixel width with how wide it appears on screen.
- Scroll slowly on a phone and watch for content jumping as images load.
- Pick three images at random and check they have meaningful alt text.
When images are the problem, they are usually the cheapest fix on the whole technical SEO checklist. When they are not, Why is my website slow? covers what to check next.