mayu

Images

Importing an image gives you its metadata: dimensions, a tiny placeholder, and every variant generated at build time. Options go in the query string of the import, so each import below produces its own set of assets from the same two JPEG files.

Responsive variants

Listing widths generates one resized file per width. The Image component puts them in srcset so the browser downloads the smallest one that fits.

Responsive = import("./mayu-dolphin.jpeg?width=320,640,960&format=webp&quality=75")
The Mayu dolphin reimagined in the jungle
Source 1024×1536, served as WebP.
VariantSizeType
320w320×480image/webp
640w640×960image/webp
960w960×1440image/webp

Format fallback

With several formats, the variants are grouped by type into <source> elements inside a <picture> element. The first format becomes the fallback <img> for browsers without WebP support.

Fallback = import("./mayu-dolphin2.jpeg?width=480,960&format=jpeg,webp&quality=80")
The Mayu dolphin reimagined in a retro landscape
Right-click and open the image in a new tab to see which file your browser picked.
VariantSizeType
480w480×720image/jpeg
960w960×1440image/jpeg
480w480×720image/webp
960w960×1440image/webp

Quality

Every quality is its own import, so all 7 files existup front. Moving the slider only changes which one the server renders.

5
The Mayu dolphin at WebP quality 5The Mayu dolphin at WebP quality 10The Mayu dolphin at WebP quality 20The Mayu dolphin at WebP quality 40The Mayu dolphin at WebP quality 60The Mayu dolphin at WebP quality 80The Mayu dolphin at WebP quality 95
640px WebP at quality 5, shown at 2× to make thecompression artifacts visible.

Placeholders

Every import carries a 295-byte data URIof the image scaled down to 16px. The components use it as a background while the real image loads, so the layout never jumps and the page is never blank.

The Mayu dolphin reimagined in a retro landscape
The placeholder, with the original JPEG fading in on top.