Menu

The picture element: which format each browser downloads
📰

The picture element: which format each browser downloads

DEV Community: html·Sahadat Husain·16 days ago
#bPJnasyr
#devto2#devto#dev#avif#jpeg
Long article (883 words) — no AI summary yet.
Reading 0:00
15s threshold

A <picture> element makes each browser download exactly one file. In my test, Chromium 149, Firefox 151 and WebKit 26.5 all picked the AVIF: 34,898 bytes, against 79,671 for the JPEG fallback. That is 44,773 bytes fewer, or 56.2%. The savings depend on two things people get wrong: source order and the type attribute.

What does the browser download from a picture element?

It walks the <source> children in order and takes the first one it can use. MDN's picture reference says a source with a type the browser does not support is skipped, and the <img> is the fallback when no source matches. The first match wins. The rest are never requested.

I made five files from one 4964 × 2782 camera photo, resized to 1280 px wide: mozjpeg q80, WebP q75 and AVIF q50 (effort 4).…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.