Browser troubleshooting

Why a small image download can use much more memory

Compressed download size and decoded image memory are different quantities. Pixel dimensions can make a highly compressed image expensive to decode and display even when its file is small.

Worked example

Browser console example · use a disposable page on your own site

const width = 4000, height = 3000;
const approximateRgbaBytes = width * height * 4;
console.log(approximateRgbaBytes / (1024 * 1024));

How it works

Four bytes per pixel gives a simple illustrative RGBA buffer estimate of about 45.8 MiB for this image. Actual browser memory can differ because of decoding formats, copies, graphics resources, and implementation details. The estimate explains why dimensions matter independently of compression.

Limits and mistakes

This arithmetic is not a measurement of a particular browser’s allocation. Animated images and multiple decoded copies can add other costs. Resize source images for the displayed purpose rather than relying only on smaller compressed byte counts.

Check the result

Expect approximately 45.78. Inspect natural image dimensions alongside network transfer size when diagnosing an image-heavy page, and compare behavior after serving appropriately sized assets.

Sources

Reference documentation for the behavior used in this guide: