Back to All Blog Posts
Image Guides

How to Optimize Images for a Faster Website: Size, Format and Loading

By 4 min read
A heavy image being reduced to a light WebP file for a web page
Short answer

Resize each image to the largest size it’s actually displayed at (about twice that for sharp phone screens), save photos as WebP at 75 to 85 percent quality, always set width and height in the HTML, add loading="lazy" to images below the fold, and never lazy-load the main image at the top of the page. These steps alone often cut image weight by more than half.

On most sites, images make up the majority of the bytes a visitor downloads. A single unedited phone photo is 3 to 5 MB, more than a whole well-built page should weigh. The good news: image fixes are mechanical. You don’t need to redesign anything.

1. Use the right dimensions

An image shown 800 pixels wide on the page doesn’t need to be 4000 pixels wide in the file. Work out the largest width each image is displayed at, then double it for high-density phone screens. For a typical blog content column that’s around 1200 to 1600 px; for thumbnails, 400 to 600 px is plenty.

Resizing alone usually does more than any compression setting. Resize Image can set width or a target file size.

2. Choose the right format

ContentFormatWhy
PhotosWebP (or AVIF)Typically 25 to 35 percent smaller than JPG at the same visual quality
Logos, icons, line artSVGTiny and sharp at any size
Screenshots, graphics with textWebP lossless or PNGKeeps edges crisp
AnimationsVideo (MP4/WebM) rather than GIFGIFs are huge for what they show

Every current browser supports WebP. Converting a folder of JPGs takes a minute with JPG to WebP or PNG to WebP. The comparison is covered in more depth in WebP vs JPG vs PNG.

3. Pick a sensible quality

Quality 100 is almost never needed. Between 75 and 85 percent, most photos look identical to the original at normal viewing size and are a fraction of the weight. Check hero images and product photos at full size; for small thumbnails, you can go lower.

4. Always set width and height

<img src="/images/shop-front.webp" width="1200" height="800" alt="Front of the shop on Main Street">

With these two attributes the browser reserves the right space before the image arrives, so text doesn’t jump down the page as images load. That jumping is measured by Google as Cumulative Layout Shift (CLS), one of the Core Web Vitals. CSS can still make the image responsive; the attributes only give the browser the shape.

5. Lazy-load below the fold, not above it

  • Add loading="lazy" to images further down the page. They load only when the visitor scrolls near them.
  • Do not lazy-load the main image at the top (the hero or first product photo). It’s usually the Largest Contentful Paint element, and lazy-loading it delays it.
  • For that top image, fetchpriority="high" tells the browser to fetch it first.

6. Serve smaller files to small screens

With srcset and sizes, the browser picks the right file for the screen:

<img src="/img/view-1200.webp"
     srcset="/img/view-600.webp 600w, /img/view-1200.webp 1200w, /img/view-1800.webp 1800w"
     sizes="(max-width: 700px) 100vw, 700px"
     width="1200" height="800" alt="View from the hotel terrace">

A phone on mobile data downloads the 600 px version instead of the 1800 px one.

7. Don’t forget the boring parts

  • File names: blue-cotton-kurta.webp tells search engines more than IMG_4521.webp.
  • Alt text: describe what the image shows, for screen readers and image search. Decorative images get empty alt (alt="").
  • Caching: serve images with long cache headers (a CDN like Cloudflare helps), and change the file name when you replace an image.
  • Metadata: stripping EXIF data saves a few KB and removes location data from photos.

Measure before and after

Run a page through Google PageSpeed Insights before you start and again after. It lists oversized images and the potential savings. Fix the biggest files first; on most sites, ten images account for most of the weight.

Frequently asked questions

What is the best image format for websites?

WebP for photos, SVG for logos and icons, and lossless WebP or PNG for screenshots with text. Every modern browser supports WebP.

What size should website images be?

The largest size they are displayed at, about twice that for sharp phone screens. For a normal content column, 1200 to 1600 px wide is usually enough.

What quality should I use when compressing images?

Between 75 and 85 percent for photos. The difference from 100 percent is not visible at normal size, and the file is much smaller.

Should I lazy-load all images?

No. Lazy-load images below the fold, but load the main image at the top of the page normally, ideally with fetchpriority="high".

Why should I add width and height to images?

So the browser reserves the space and the page does not jump as images load, which improves Cumulative Layout Shift.

Convert your images to WebP

Smaller files at the same visual quality, converted in your browser.

Open JPG to WebP
Akhtar Ali

Founder of CleanPDF. I build the site’s browser-based PDF, image, QR code and calculator tools, and I write these guides around the questions people send in while using them.