Why image weight matters so much
Images take up most of a page's weight. When a person on a phone waits for the main photo to load, they see a blank screen, and on mobile internet with an unstable connection it takes especially long. Search engines take speed into account, and visitors leave without waiting.
A photo from a modern phone is thousands of pixels on each side, but it is displayed on screen at a width of about 400-1200. The rest is excess weight that your visitor and your traffic pay for.
Image formats
- WebP
- A modern format with good compression, supported by all current browsers. The main choice for photos and graphics.
- AVIF
- Even smaller size at the same quality, but encoding takes longer. Suitable for large images when your build supports it.
- JPEG
- A universal option for photos if you need compatibility with older systems.
- PNG
- Needed only for images with transparency and sharp edges. Heavy for photos.
- SVG
- A vector format for logos and icons: it weighs little and stays sharp.
What to do with each image
Pick the size
Upload an image no wider than it is displayed, with a 2x margin for high-density screens.
Compress
Online services and build tools cut the weight several times over with almost no visible loss of quality.
Choose the format
WebP as the default, SVG for the logo and icons.
Set dimensions in the code
Width and height prevent the page from jumping while loading.
Enable lazy loading
Images below the first screen load when the visitor scrolls to them.
Common mistakes
- The main photo on the first screen is lazy-loaded, although it should appear immediately
- The same large file is used as a small thumbnail
- A video background replaces a photo without need, yet weighs as much as dozens of images
- Images have no alt text, which hurts accessibility and image search
- Text is baked into images, and search engines do not read it
- A ten-slide carousel loads all the images at once