# Image Optimization for the Web: AVIF, WebP, srcset and Lazy Loading

- Link: https://bestwebdeveloper.org/image-optimization-avif-webp-srcset-lazy-loading/
- Published: 2026-12-02T17:00:00+00:00
- Author: Best Web Developer

Last updated: September 2026 · Reading time: 13 min · By the Best Web Developer 
team

![Image optimization workflow comparing AVIF, WebP and JPEG file sizes for a fast
mobile website](https://placehold.co/1200x630/f97d0a/ffffff/png?text=Image+Optimization
+Guide)

The same product photo exported as JPEG, WebP and AVIF. On most photographic content
the modern formats cut file weight by a third or more with no visible loss.

Quick answer

Good image optimization means serving AVIF first, WebP as the fallback and JPEG 
or PNG only for old browsers, at the exact size each screen needs via srcset and
sizes. Always set width and height, lazy-load images below the fold, and never lazy-
load the main hero image. Done together, this usually halves page weight and improves
LCP.

Key takeaways

 * Images are usually the heaviest part of a page, so they are the fastest route
   to better Core Web Vitals.
 * AVIF typically beats WebP on photos, and WebP typically beats JPEG. Serve both
   through the picture element or an image CDN.
 * srcset with an accurate sizes attribute stops phones downloading desktop-sized
   images.
 * Lazy loading helps images below the fold but hurts LCP when applied to the hero.
   Use fetchpriority=”high” on the hero instead.
 * For Saudi stores on Salla, Zid, Shopify or WordPress, most gains come from upload
   discipline and theme settings, not new software.

## Why image optimization is the quickest speed win on most websites

Image optimization is usually the quickest speed win because images make up the 
largest share of bytes on a typical page. Public data from the [HTTP Archive](https://httparchive.org/)
has shown this pattern for years, and our own audits agree: on the Saudi business
sites we review, images typically account for 45–70% of total page weight.

**Image optimization** is the practice of delivering every image in the smallest
file, the right format and the right dimensions for the device requesting it, at
the moment it is needed. It covers four decisions: format, compression level, responsive
sizing and loading priority.

This guide walks through each decision in the order we apply them on client projects.
It is written for marketers and site owners as much as developers, so every technique
includes what to ask your developer or which setting to change in your platform.

Note: how to read the savings figures

Compression savings depend heavily on the source image. A flat logo, a product shot
on white and a busy street photo all compress differently. The percentages in this
guide are typical ranges observed in our audits and tests, not guaranteed results.
Always measure your own images before and after.

---

## Choosing formats: AVIF vs WebP vs JPEG vs PNG vs SVG

Use AVIF for photos where you can, WebP as the safe modern default, SVG for logos
and icons, and keep JPEG or PNG only as a fallback. Each format has a job, and the
wrong one can make a file five times heavier than it needs to be.

### AVIF: smallest files for photographs

**AVIF** is an image format based on the AV1 video codec that supports lossy and
lossless compression, transparency and HDR. In our tests, AVIF files at matching
visual quality are typically 30–50% smaller than a well-compressed JPEG. Current
versions of Chrome, Edge, Firefox and Safari all decode it. The trade-offs are slower
encoding and occasional smoothing of fine texture, such as fabric weave, at aggressive
settings.

### WebP: the reliable modern default

**WebP** is a format developed by Google that handles both photos and graphics with
transparency. Savings over JPEG are typically 25–35% on photos, and over PNG often
much more on transparent graphics. Browser support is effectively universal today,
so WebP is the right fallback when AVIF is not available or encoding time matters.

### SVG, PNG and JPEG: where they still belong

SVG is vector, so logos, icons and simple illustrations stay sharp at any size and
often weigh under 5 KB. Run SVGs through an optimiser to strip editor metadata. 
PNG is still useful for screenshots with sharp text when you need lossless output,
and JPEG remains the universal fallback. A 2.4 MB PNG hero photo is one of the most
common problems we find; the same image as AVIF is often under 150 KB.

 | Format | Best for | Typical size vs JPEG | Watch out for | 
  | AVIF | Photos, hero banners, product shots | 30–50% smaller | Slow encoding, texture smoothing | 
 | WebP | Photos and transparent graphics | 25–35% smaller | Slightly larger than AVIF | 
 | JPEG | Universal fallback | Baseline | No transparency | 
 | PNG | Lossless screenshots, pixel art | Often 3–10x larger for photos | Never use for photos | 
 | SVG | Logos, icons, diagrams | Tiny for simple shapes | Sanitise uploaded SVGs for security |

---

## Responsive image optimization with srcset and sizes

srcset lets the browser pick the smallest file that still looks sharp on the current
screen, and sizes tells it how wide the image will actually display. Without them,
a phone on a 4G connection in Dammam downloads the same 2,000-pixel image as a 27-
inch desktop monitor.

### How width descriptors work

A **srcset** attribute is a list of image files with their pixel widths, such as
photo-480.avif 480w, photo-960.avif 960w and photo-1600.avif 1600w. The **sizes**
attribute describes the display width at each breakpoint, for example “(min-width:
1024px) 50vw, 100vw”. The browser combines that with the screen’s pixel density 
and chooses one file. [MDN Web Docs](https://developer.mozilla.org/en-US/) has the
full syntax reference.

In responsive image optimization, the most common mistake we see is a missing or
lazy sizes value. If sizes is omitted, the browser assumes the image fills 100% 
of the viewport width, so a thumbnail in a four-column grid downloads a file four
times too large.

### The picture element for format fallback

The picture element wraps several source elements, each with a type such as image/
avif or image/webp, followed by a normal img tag as the fallback. The browser uses
the first source it supports. Put the width, height, alt, loading and fetchpriority
attributes on the inner img tag, because that is the element the browser actually
renders and measures.

Picture also handles art direction: a wide banner on desktop and a tighter, square
crop on mobile. This matters for bilingual Saudi sites, where a crop that works 
for a left-to-right English headline may hide the subject behind right-to-left Arabic
text.

![Diagram of srcset and sizes attributes selecting responsive images for phone, 
tablet and desktop screens](https://placehold.co/1200x675/14181d/fed7aa/png?text
=srcset+and+sizes+Explained)

With accurate sizes values, a 390-pixel-wide phone at 3x density picks the 1280w
file rather than the 2000w original.

## Lazy loading, priority hints and Core Web Vitals

Lazy-load everything below the first screen and eagerly load, with high priority,
the single image most likely to be the Largest Contentful Paint. Get this backwards
and you can make LCP worse while believing you optimised it.

### Native lazy loading

Adding loading=”lazy” to an img tag tells the browser to defer the download until
the image approaches the viewport. It needs no JavaScript and is supported by all
major browsers. WordPress adds it to content images automatically, and most Shopify
themes use it on collection grids.

### Protecting LCP

Google’s [Largest Contentful Paint guidance](https://web.dev/articles/lcp) sets 
a good threshold at 2.5 seconds or less. On most landing pages the LCP element is
the hero image. Give it fetchpriority=”high”, do not lazy-load it, and avoid loading
it through a CSS background or a JavaScript slider, both of which hide it from the
browser’s preload scanner. A single change here often moves mobile LCP by 0.5–1.5
seconds.

### Preventing layout shift

Every image needs width and height attributes, or a CSS aspect-ratio, so the browser
reserves space before the file arrives. Missing dimensions are the most frequent
image optimization failure we find and the main cause of poor Cumulative Layout 
Shift, and Google’s [CLS guidance](https://web.dev/articles/cls) treats 0.1 or less
as good. Set height:auto in CSS so the image still scales responsively.

Pro tip

Hero sliders with five rotating banners are an LCP trap: the browser often fetches
all five at once. If marketing insists on a slider, load only the first slide eagerly
and lazy-load the rest. Better still, test a single static hero. On the Saudi retail
sites we have tested, a static hero rarely lowers click-through.

Highlight: our image optimization checklist

1) Hero image under 200 KB, AVIF or WebP, fetchpriority=”high”, not lazy. 2) Every
img has width, height and descriptive alt text. 3) srcset with four to six widths
and an accurate sizes value. 4) loading=”lazy” on everything below the fold. 5) 
No PNG photos and no images wider than 2x their display size. 6) Logos and icons
as optimised SVG. 7) Long cache headers on image files. Check uploads with our free
[Image Inspector](https://bestwebdeveloper.org/tools/image-inspector/) to see dimensions,
format and file weight before they go live.

---

## Our process: image optimization on WordPress, Shopify, Salla and custom builds

The process is the same on every platform: fix the source files, automate format
conversion, then check the output in real field data. What changes is where each
step lives.

 1. **Audit the top 20 pages.** Run each through PageSpeed Insights on mobile and list
    every image over 150 KB, every missing dimension and the LCP element.
 2. **Set an upload standard.** Photos exported at no more than 2,400 pixels wide, 
    sRGB colour, quality around 80, with no text baked into the image.
 3. **Automate conversion.** Use an image CDN, a build step with a library such as 
    sharp, or a platform feature to generate AVIF and WebP in several widths.
 4. **Fix templates.** Add sizes values, priority on the hero and lazy loading below
    the fold in the theme code, so every new page inherits them.
 5. **Clean the media library.** Replace legacy multi-megabyte originals on high-traffic
    pages first.
 6. **Verify in field data.** Watch Core Web Vitals in Search Console for 28 days, 
    because lab scores alone do not prove users saw the change.

### Platform notes

 * **WordPress:** creates srcset automatically for content images and accepts AVIF
   uploads in recent versions. A conversion plugin or CDN handles the rest; avoid
   stacking several optimisation plugins that fight each other.
 * **Shopify:** the Shopify CDN resizes images by URL parameter and serves modern
   formats to supporting browsers. Most gains come from theme code that requests
   the right width.
 * **Salla and Zid:** you control less of the markup, so upload discipline matters
   most. Compress banners before upload and keep product photos to a consistent 
   square ratio.

If your theme needs template-level fixes, our [technical SEO services](https://bestwebdeveloper.org/services/technical-seo-services/)
team handles image audits alongside the rest of a Core Web Vitals programme.

## Key benefits of image optimization for business websites

The benefits show up in speed, search, conversion and running costs. Most of them
compound, because a lighter page is faster for every visitor on every visit.

 * **Faster LCP:** a lighter hero is the single biggest lever on the metric most
   sites fail.
 * **Stable layouts:** reserved dimensions remove the jumps that cause mis-taps 
   on checkout buttons.
 * **Better search visibility:** page experience is one of many ranking signals,
   and descriptive alt text helps Google Images and AI answers understand products.
 * **Higher conversion on mobile:** in our project experience, shaving a second 
   off mobile load time lifts add-to-cart rates on image-heavy stores.
 * **Lower bandwidth bills:** CDN and hosting costs fall roughly in line with bytes
   served.
 * **Better accessibility:** an alt-text audit is part of the same pass and supports
   WCAG 2.2 conformance.

> “The best image optimization tool is an upload rule everyone follows. Software
> fixes yesterday’s files; a standard fixes tomorrow’s.”
> — Best Web Developer strategy
> team

## Use cases in Saudi Arabia: stores, real estate and bilingual campaigns

Saudi websites are heavily mobile, visually rich and often bilingual, which makes
image weight a bigger issue than on many Western sites. Three situations come up
in almost every Saudi project we audit.

### Fashion, abaya and perfume stores

Collection pages with 40–60 product photos, each with a hover image, can exceed 
15 MB when uploaded straight from a photographer. Lazy loading plus correctly sized
WebP or AVIF thumbnails typically brings that under 2 MB. Traffic peaks during Ramadan,
White Friday and around Saudi National Day on 23 September, exactly when slow pages
cost the most.

### Real estate and hospitality galleries

Project pages for Riyadh and Jeddah developments often load 30 full-resolution renders
on first view. Load the first image eagerly, lazy-load the rest, and serve gallery
thumbnails at thumbnail size, opening the large file only when the visitor taps 
it.

### Arabic and English campaign banners

Banners with Arabic text baked into the image double the asset count, cannot be 
translated, are invisible to search engines and screen readers, and blur when compressed.
Keep text as live HTML over the image where possible, which also makes right-to-
left layouts easier to maintain.

Illustrative case: a Riyadh perfume store before White Friday

**Challenge:** A WooCommerce store with 900 products had a 7.8 MB homepage, a five-
slide PNG hero and a mobile LCP of 5.4 s. Mobile conversion sat at 0.9% while desktop
converted at 2.1%.

**What we did:** Over three weeks and a budget of SAR 14,500, we replaced the slider
with one AVIF hero at 140 KB, added srcset and sizes to theme templates, lazy-loaded
grids, added dimensions everywhere and re-exported the 60 top-selling product photos.

**Result:** Homepage weight fell from 7.8 MB to 1.6 MB, mobile LCP from 5.4 s to
2.2 s and CLS from 0.24 to 0.03. Over the following White Friday period, mobile 
conversion reached 1.5%.

---

## Comparing image delivery approaches: manual, plugin, build step or image CDN

An image CDN is the least effort for most businesses, a build step suits custom 
sites, and plugins suit WordPress. Manual export works only for very small sites
that rarely change.

 | Approach | Typical cost (SAR) | Strengths | Weaknesses | 
  | Manual export (Squoosh, Photoshop) | Staff time only | Full control per image | Does not scale, easy to forget | 
 | WordPress plugin | 0–400 per year | Converts existing library | Server load, plugin conflicts | 
 | Build step (sharp, framework image component) | Developer setup, 3,000–8,000 one-off | Free at runtime, precise | Needs a developer for changes | 
 | Image CDN (for example Cloudflare Images) | Usage-based, often 40–400 per month | Automatic formats and sizes at the edge | Ongoing cost, vendor dependency | 
 | Platform built-in (Shopify, Salla, Zid) | Included in plan | No setup | Limited control over markup |

Whichever route you choose, the template work is the same. Our [web development service](https://bestwebdeveloper.org/services/web-development/)
builds srcset, priority hints and lazy loading into themes so the results survive
future content updates.

Highlight: alt text is part of the job

Write alt text that describes what the image shows and why it is there, in the language
of the page. An Arabic product page needs Arabic alt text, not the English file 
name. Decorative images get an empty alt attribute so screen readers skip them. 
Good alt text also gives Google and AI assistants a plain-language description of
your products.

## Future trends: images, Vision 2030 and the next few years

Expect AVIF to become the default output of most platforms, image CDNs to become
standard on mid-sized sites, and Saudi buyers to judge private-sector sites against
fast Vision 2030 government services.

 * **AI-generated product imagery:** faster to produce, but files from generators
   are often huge PNGs. The same upload standard applies.
 * **Visual search and AI answers:** clear, well-described product images are increasingly
   surfaced in visual and AI-driven search results.
 * **Digital government as benchmark:** Vision 2030 digital services have set Saudi
   expectations for speed on mobile, and slow commercial sites now stand out more.
 * **Accessibility in tenders:** WCAG 2.2 requirements, including alt text, are 
   appearing in more procurement documents.

---

## Frequently Asked Questions about web images

### Is AVIF better than WebP for websites?

For photographs, AVIF usually produces smaller files than WebP at the same visual
quality, often by a further 15–25% in our tests. WebP encodes faster and can handle
some graphics better. The practical answer is to serve AVIF first with WebP as a
fallback, using the picture element or an image CDN that chooses automatically for
each browser.

### Should I lazy load all images on my website?

No. Lazy-load images that sit below the first screen, such as product grids, galleries
and blog images further down the page. Do not lazy-load the hero or any image likely
to be the Largest Contentful Paint element, because that delays the most important
paint. Give that image fetchpriority=”high” and load it normally instead.

### What is the ideal image file size for a web page?

There is no single rule, but useful targets are under 200 KB for a full-width hero,
under 100 KB for in-content images and under 40 KB for product thumbnails. Total
image weight for a typical landing page should ideally stay below 1–1.5 MB on mobile.
Heavier pages are possible but usually mean images are oversized or in the wrong
format.

### What does the sizes attribute do in srcset?

The sizes attribute tells the browser how wide an image will be displayed at different
screen widths, before the page layout is calculated. The browser combines that with
the screen’s pixel density to pick the best file from srcset. Without sizes, it 
assumes the image fills the full viewport width and often downloads a file several
times larger than needed.

### How do I optimise images on a Salla or Zid store in Saudi Arabia?

Salla and Zid handle hosting and much of the delivery, so focus on what you upload.
Resize photos to about 2,000 pixels on the longest side, compress them to WebP or
high-quality JPEG before upload, keep a consistent square ratio for products and
avoid Arabic text baked into banners. Then test key pages on mobile with PageSpeed
Insights.

### Do images affect SEO rankings?

Yes, in several ways. Heavy images slow LCP, which feeds into page experience signals.
Descriptive file names and alt text help Google Images and AI features understand
what a picture shows. Structured data can connect product images to prices and reviews.
Images alone will not rank a weak page, but slow, unlabelled images can hold a strong
page back.

### How much does an image performance audit cost in Riyadh?

Typical ranges we quote are SAR 3,000–7,500 for an audit of the top 20 pages with
a prioritised fix list, and SAR 8,000–25,000 for audit plus template fixes, media
library clean-up and a 28-day field data review. Large catalogues with thousands
of legacy images or custom platforms sit at the upper end of that range.

## Making image optimization a habit, not a one-off project

Image optimization comes down to four decisions made consistently: modern formats,
the right dimensions through srcset and sizes, reserved space with width and height,
and the right loading priority. Get those right in your templates and every new 
page benefits automatically.

Start with the pages that earn money, measure LCP and CLS before and after, and 
write an upload standard your whole team follows. For Saudi businesses competing
on mobile, that discipline is one of the cheapest performance gains available.

Find out what your images are costing you

Send us your URL and we will return a free image audit of your top pages, with LCP
and CLS fixes ranked by impact.

 [Get a free consultation](https://bestwebdeveloper.org/contact/) [See pricing](https://bestwebdeveloper.org/pricing/)

**Tags:** image optimization, AVIF, WebP, srcset, lazy loading, responsive images,
Core Web Vitals, LCP, CLS, page speed, Saudi e-commerce

Further reading

 * [Cumulative Layout Shift: 12 Causes and Their Fixes](https://bestwebdeveloper.org/cumulative-layout-shift-causes-fixes/)
 * [Interaction to Next Paint (INP): Why It Matters and How to Fix It](https://bestwebdeveloper.org/interaction-to-next-paint-inp-fix/)
 * [How to Fix Largest Contentful Paint (LCP) Step by Step](https://bestwebdeveloper.org/how-to-fix-largest-contentful-paint/)
