On nearly every slow site we are asked to look at, images are the problem. Not the code, not the hosting. The pictures.

Why it happens

Phones take enormous photos. Someone uploads one straight off the camera roll, 4 000 pixels wide and several megabytes, to display at 600 pixels. The browser downloads all of it and throws most away.

What WebP is

An image format that produces noticeably smaller files than JPEG or PNG at the same visual quality. Every current browser supports it.

Real numbers from this site

When we moved our own images to WebP, the whole image library went from 5.2MB to 2.8MB, while adding more sizes for different screens. One illustration dropped from 210KB to 30KB. Nothing looks worse.

WebP also supports transparency, which let us delete a pile of separate mask files that only existed to work around PNG being heavy. Two requests became one.

The other half: correct sizes

Format alone is not enough. An image shown at 400 pixels on a phone should not be a 1 600 pixel file. Done properly, a site serves several sizes and the browser picks.

Lazy loading

Images below the fold should not load until someone scrolls near them. One attribute, supported everywhere, and it takes a large chunk off initial load.

What to do

  1. Resize before uploading. Nothing on a normal site needs to be wider than 2 000 pixels.
  2. Convert to WebP. Plenty of free converters, and good hosting can do it automatically.
  3. Always set width and height, so the page does not jump while loading.
  4. Lazy load anything below the fold.

Do those four and most slow sites get noticeably quicker without touching anything else.