Allscreenshots
Sign inGet an API key
Blog

Engineering

When a smaller AVIF makes your screenshot pipeline slower

Erik Lindqvist6 min read

Your screenshot is ready, but the request is still running. The browser has finished its work. Now an encoder is spending hundreds of milliseconds making the output smaller.

That can be a sensible trade for an image you will serve all week. It can also be the wrong trade for a preview that one person opens once.

We measured both sides using a screenshot of NASA's Image of the Day gallery: output bytes and local encoding time. At similar measured quality, AVIF saved substantial space compared with JPEG. Turning up AVIF's encoding effort, however, bought much smaller additional savings.

The image we timed

Source screenshot used for the When a smaller AVIF makes your screenshot pipeline slower experiment
NASA Image of the Day gallery, captured 29 September 2026. Page and image credits: NASA and the contributors credited on the source gallery. View source page.

This is a 1280 × 800 viewport captured on 29 September 2026. It includes photographs, gradients, fine detail, text, and large areas of flat background. It is a screenshot of the gallery page, not a set of original camera files.

We captured one PNG through AllScreenshots, normalized it to opaque 8-bit sRGB, and reused those pixels for every export. Timings exclude navigation and capture. They also exclude normalization, quality scoring, and decoding for inspection.

EncodingSizeEncode timeSSIMULACRA 2
PNG, level 91285.2 KiB59.8 ms100.0
JPEG, q80 / 4:4:4167.0 KiB9.2 ms79.5
WebP, q80 / effort 681.5 KiB107.1 ms69.6
AVIF, q80 / effort 6125.0 KiB798.2 ms87.2
JPEG XL, q80 / effort 7102.5 KiB213.0 ms75.0
JPEG, q60 / 4:4:4111.1 KiB8.6 ms70.3
WebP, q60 / effort 657.2 KiB91.6 ms64.0
AVIF, q60 / effort 670.1 KiB669.9 ms78.8

The figures are medians of three sequential runs after one untimed warm-up on an Apple Silicon Mac. They include writing the file. Sharp encoders read in-memory RGB; JPEG XL's command-line path also starts a process and decodes a PNG. That difference is part of this pipeline measurement and prevents treating the table as a pure codec speed ranking. The full report records hardware and library versions.

Compare similar quality, not matching slider values

JPEG at quality 80 scored 79.5. AVIF at quality 60, effort 6 scored 78.8. Those SSIMULACRA 2 scores are close enough to make a useful local comparison, though they are not a controlled subjective quality match.

The JPEG was 167.0 KiB; that AVIF was 70.1 KiB. AVIF used about 58% fewer bytes. It also took about 670 ms to encode, against roughly 9 ms for JPEG.

The quality-60 WebP was smaller still, at 57.2 KiB, but its score was 64.0. Calling it the winner without mentioning the quality difference would be misleading.

Labeled comparison of the same screenshot crop after decoding each tested format
Decoded crops at 3× nearest-neighbor enlargement. Click to inspect the PNG comparison at full size.

Look at the galaxy's fine structure and the transitions around bright regions. These strips show decoded pixels, enlarged three times and preserved in PNG. At these settings, the lower-quality exports smooth some detail; the amount and character of that smoothing differ. The full screenshot may hide differences that matter in a large crop.

Download the JPEG q80, AVIF q60, and WebP q60 to judge the intended display size yourself.

Effort is a separate budget

We encoded AVIF quality 60 at effort 4 and effort 6:

EncodingSizeEncode timeSSIMULACRA 2
AVIF, q60 / effort 471.0 KiB250.9 ms78.2
AVIF, q60 / effort 670.1 KiB669.9 ms78.8

Effort 6 saved 934 bytes in this sample and took about 419 ms longer. Its quality score improved slightly, too. The result is not “never use effort 6.” It is a reason to benchmark effort independently of quality.

At 10 Mbit/s, transferring 934 bytes takes roughly 0.75 ms in an idealized calculation. That excludes latency, protocol overhead, contention, and decoding. It is a bandwidth illustration, not a measured improvement in page load time.

If the image is encoded once and downloaded a million times, those bytes add up. If you re-encode on every request, the processing work adds up as well. The right setting depends on which event repeats.

Split the pipeline into things you can measure

StageUseful measurementWhat this experiment measured
Navigate and renderTime until the page is readyNot included
CaptureTime to produce the source pixelsNot included
EncodeWall time for a selected conversion pathIncluded
Store and transferStored bytes, request overhead, throughputOutput file bytes only
Decode and paintTime until the viewer sees the imageNot included

A smaller image does not establish a faster Largest Contentful Paint. Browser decoding, source selection, network conditions, image priority, and the surrounding page still need testing. A command-line encoder benchmark cannot settle that question.

For an interactive capture endpoint, return or store an acceptable first result and generate slower derivatives in a background job where the product permits it. For a static article or cached gallery, encode once and reuse the derivative.

Put dimensions before expensive encoder settings

This experiment deliberately held dimensions constant to isolate conversion settings. A real pipeline should also compare the dimensions it needs to serve.

Do not deliver a full-size screenshot to a tiny card solely because AVIF made the file tolerable. Create an appropriately sized derivative, keep a larger source for zooming, and include dimensions in the cache key. Otherwise, an image captured for a 320-pixel card may accidentally be reused in a 1200-pixel detail view.

Delivery needs a fallback

AVIF has support in current major browsers. A JPEG or WebP fallback still covers older clients and integrations. The browser can select a supported source through the standard picture element:

html
<picture> <source srcset="/captures/gallery.avif" type="image/avif"> <source srcset="/captures/gallery.webp" type="image/webp"> <img src="/captures/gallery.jpg" width="1280" height="800" alt="A gallery of space and science photographs"> </picture>

Those files must already exist. This markup does not run the encoders or compare quality for you. Store the derivatives under distinct URLs and send the matching content types.

A useful default comes from the workload

For this capture, AVIF offered a useful size reduction at a quality score close to JPEG's. The higher AVIF effort setting offered a much smaller marginal reduction. That gives us two separate decisions: whether to use AVIF, and how much time to spend encoding it.

Measure both on your own pages. Keep capture latency, conversion time, and delivery performance separate, then optimize the stage your users actually wait for. AllScreenshots handles the source capture; local or background conversion lets you choose the delivery tradeoff.

Find out how easy it is to capture and share pixel-perfect screenshots at scale using Allscreenshots. Sign up for a free account and start integrating your first screenshot API call today.

Start with one request

Free plan: 100 screenshots. No credit card.

Get an API key
  • Full-page captures
  • Popups and repeated sticky bars removed
  • Markdown, JSON and PDF output
  • Crawl a site from one URL
  • Desktop, tablet and phone in one image
  • Works in n8n, Make and Zapier
  • MCP server for AI assistants