Skip to content
All writing
Engineering · 9 min read

Image Format Benchmark: 5,625 Runs Later, WebP Wins

We benchmarked 75 production images across WebP and AVIF with 6,075 automated runs. WebP won on decode speed, coverage, and time-to-paint. This is the overview and the verdict.

The goal: faster paint, not smaller files

Every millisecond between request and paint is a millisecond the user stares at nothing. On a mid-tier phone over slow 3G, that gap decides whether the image shows at all.

We wanted to answer one question. Can a format change make the serving experience measurably better? Not “can we save bytes.” Can the user see the image sooner, on more devices.

When the image reaches the screen faster, three things improve:

  1. The image paints earlier. The user sees it sooner. In ad serving, the ad renders before the user scrolls past it.
  2. Slow networks stop timing out. A 900 ms download on slow 3G becomes 530 ms. The image arrives in time.
  3. Weak CPUs keep up. A phone in low-battery mode throttles its CPU. A lighter decode means the image still finishes before the next frame.

CDN cost also drops, but that is a side effect, not the goal.

The formats: what we serve today vs what exists

Today we serve three formats: JPEG (photos), GIF (animation), PNG (transparency). Two modern alternatives exist:

  • WebP (Google, 2010). Lossy and lossless modes. Animated WebP replaces GIF. Browser support: 97% globally.
  • AVIF (AOM, 2019). Based on the AV1 video codec. Higher compression ceiling than WebP. Browser support: 95%.

The tradeoff is not just “which compresses more.” Three axes matter for serving:

Format Tradeoff: Three Axes Compression Decode cost Coverage WebP 47-83% 2-3 ms 97% 3 / 3 AVIF 38-81% 8-32 ms 95% 1 / 3 AVIF compresses more, but decode cost on weak devices eats the savings. WebP balances all three axes.
WebP wins on three of three axes. AVIF wins only on compression.

Terms you will see in this series

This series uses metrics from web performance and image encoding. Each term appears again with an inline definition at first use in every part. This table is a reference card.

TermPlain words
LCPLargest Contentful Paint. The moment the user sees the image. The main speed metric of this series.
Decode timeCPU work to turn downloaded bytes into pixels. Heavier compression costs more decode work.
SSIMStructural Similarity, 0 to 1. How close the converted image looks to the original. Above 0.95, most people see no difference.
TTFBTime To First Byte. How fast the server starts sending. The image format has no effect on this metric.
CPU throttleChrome DevTools can slow the CPU by N times to simulate a weaker phone. 1x = desktop. 4x = mid-tier. 6x = low-end.
Cold / WarmDoes the CDN already hold the file? Warm = fast. Cold = first load, slower.
q (quality)The encoder quality knob, 0 to 100. Higher keeps more detail and makes a larger file.
CDPChrome DevTools Protocol. The programmatic interface we used to control Chrome.

The experiment machine: how CDP automated 6,075 runs

Running 75 images times 3 formats times 3 CPU tiers times 5 repeats by hand is 3,375 clicks. We built a pipeline instead.

The core idea: every run follows the same steps, and CDP makes those steps programmable. One test page loads one image, collects the metrics, and exits. Playwright (headless Chrome) drives that page thousands of times with CDP controlling four variables:

  • CPU throttle via Emulation.setCPUThrottlingRate. Three tiers: 1x (desktop), 4x (mid-tier phone), 6x (low-end phone).
  • Network emulation via Network.emulateNetworkConditions. Two profiles: fast 4G (9 Mbps, 60 ms) and slow 3G (1.6 Mbps, 300 ms).
  • Fresh incognito context per run. This gives cache isolation without restarting the browser.
  • Metric collection from four browser APIs. Element Timing gives load and render timestamps. Resource Timing gives download duration. The LCP observer gives time-to-paint. img.decode() gives the isolated CPU decode cost.

The same test page served all three experiments. Only the controlled variable changed:

Three Experiments, One Pipeline Experiment A Decode cost (localhost) No network noise 3 CPU tiers x 5 repeats 3,375 Experiment A2 Local + network throttle Fast 4G and slow 3G 15 images x 2 profiles 450 Experiment B Full CDN route (production) Storage to LB to CDN to browser Cold/warm classified per run 2,250 Total: 6,075 automated runs Same test page. Same metrics. Same statistical validation. CDP made the only variable the one we controlled.
CDP turned a manual spot-check into 6,075 measured runs from one machine.

Experiment A answers: “What is the pure CPU cost of each format?” It runs on localhost, so download time is near zero.

Experiment A2 answers: “On a constrained network, does the byte savings outweigh decode cost?” It adds network throttle on localhost.

Experiment B answers: “Through the real CDN, which format paints fastest?” It runs on the production path with cold/warm cache classification per run.

Statistical validation uses the paired Wilcoxon signed-rank test across all 75 images per condition. This is a non-parametric test. It does not assume the data follows a normal distribution.

Key results (quality q80, median values)

75 production images: 25 JPEG, 25 GIF, 25 PNG. All files come from the production environment. Pixel sizes range from 200x200 to 1200x627.

Overall compression

SourceWebP savings (p50)WebP SSIMAVIF savings (p50)AVIF SSIM
JPEG47.1%0.97938.2%0.986
GIF51.0%0.98054.0%0.994
PNG82.9%0.98281.0%0.992

WebP compresses JPEG and PNG more than AVIF at the same quality setting. AVIF compresses GIF slightly more. The difference is 3 percentage points.

Decode time (CPU cost to turn bytes into pixels)

CPU tierOriginal (p50)WebP (p50)AVIF (p50)
Desktop (1x)1.2 ms2.2 ms7.6 ms
Mid-tier phone (4x)1.6 ms2.5 ms3.9 ms
Low-end phone (6x)2.3 ms3.4 ms31.9 ms

WebP adds 1 ms of decode cost on a low-end phone. AVIF adds 29.6 ms. That gap matters on real devices. A phone in low-battery mode throttles its CPU the same way. Every extra millisecond of decode eats into the time the user waits.

Combined: download + decode on slow 3G, mid-tier phone

FormatMin (ms)Median (ms)Max (ms)
Original4389396,777
WebP4105341,466
AVIF4135471,406

The median image paints 405 ms earlier with WebP. That is 43% faster. AVIF is close to WebP here because the smaller file offsets the heavier decode. The max column shows the worst case per format. WebP and AVIF are similar, but the median favors WebP.

Deeper breakdowns (per source format, per CPU tier, per network profile) are in Part 02: WebP vs AVIF.

The verdict

Replace all GIF with animated WebP. Convert JPEG and PNG to WebP as a second batch. Ship AVIF later, behind a <picture> fallback.

ConversionRecommendationBasis
GIF to animated WebPReplace all51% smaller, animation preserved, 25/25 integrity pass
JPEG to WebPSecond batch47% smaller, 0.979 SSIM, encode 24x faster than AVIF
PNG to WebPSecond batch83% smaller, 0.982 SSIM
AVIFNext milestone (M2)Higher compression but 32 ms decode on low-end, 95% coverage
Quality settingq80 for JPEG/GIF, q95 for PNGLossy sources hold limited detail. See Part 03.

What to take away

  1. Benchmark your own traffic. Published comparisons use synthetic test images. Your production images have a different size distribution and device profile. Test with your own data.
  2. Decode cost matters as much as file size. AVIF compresses more. Its decode time on low-end devices (31.9 ms at 6x throttle) can eat the download savings. The format with the best compression is not always the format with the fastest paint.
  3. CDP turns spot-checks into thousands of runs. One Playwright script and one test page produced 6,075 data points. Without CDP automation, this benchmark takes weeks of manual work.
  4. If the format lacks full browser support, direct replacement breaks some users. WebP support is 97%, so 3% of browsers show a broken image. Read your traffic data first. The <picture> element closes this gap. That is why AVIF (95%) sits in M2.

This series has three deep-dive parts. Each carries the full data tables and inline diagrams.

  • Part 01: GIF to Animated WebP: the biggest savings. Size reduction, animation integrity, the animated AVIF pitfall with libvips, and encode time.
  • Part 02: WebP vs AVIF: head-to-head. File size, decode time per CPU tier, download time per network profile, and the five criteria for the winner.
  • Part 03: Shipping WebP: quality, coverage, and the road to AVIF. One quality per source format, the 3% gap, and the M2 roadmap.

For format fundamentals, see the Crop, Resize, Fill: Image Processing series. The ad serving flips the format priority post bridges “how formats work” and “how to benchmark them.”


References:

Tags #image-optimization #web-performance
// connect

Be brave | Be wise | Be grateful

21 BreakinCode

// elsewhere
LinkedInMedium (lang: en)Life RecordYoutube
wh:~$William Hung· © 2026 Taipei · GMT+8 · Available for collaboration