Welcome to Vanilla Breeze
This bell pulls live notifications from /go/notify/messages — the same contract documented at /docs/concepts/service-contracts/. Static articles like this one are the no-JS / no-backend fallback.
This bell pulls live notifications from /go/notify/messages — the same contract documented at /docs/concepts/service-contracts/. Static articles like this one are the no-JS / no-backend fallback.
Simplified responsive image API with auto-calculated sizes, srcset shorthand generation, and optional dev overlay showing the selected source.
The data-responsive attribute upscales native srcset and sizes with two features developers frequently get wrong: automatic sizes calculation from rendered layout width, and a compact shorthand for generating srcset from a list of widths.
<img data-responsive src="hero.jpg" srcset="hero-400.jpg 400w, hero-800.jpg 800w, hero-1200.jpg 1200w" alt="Hero image">
The enhancement does three things:
ResizeObserver measures the image’s rendered CSS pixel width and sets sizes to match. This ensures the browser always picks the closest source for the actual layout.data-responsive has a value (comma-separated widths), it generates srcset from the src by inserting -{width} before the file extension.loading="lazy" and decoding="async" if not already specified.Instead of writing verbose srcset attributes, provide the widths and the enhancement generates sources from your src filename:
<img data-responsive="400,800,1200" src="hero.jpg" alt="Hero image"> <!-- Generates: srcset="hero-400.jpg 400w, hero-800.jpg 800w, hero-1200.jpg 1200w" sizes="[auto-calculated]px" loading="lazy" decoding="async"-->
The naming convention inserts -{width} before the extension. So photo.jpg with widths 400,800 produces photo-400.jpg 400w, photo-800.jpg 800w.
| Attribute | Value | Description |
|---|---|---|
data-responsive |
empty or widths | Enable auto-sizes. Optionally provide comma-separated widths (e.g. "400,800,1200") to generate srcset. |
data-responsive-debug |
boolean | Show a dev overlay badge on the image displaying the current source filename and natural width. |
Add data-responsive-debug to see which source the browser selected. The overlay shows the filename and natural pixel width, updating on each load.
<img data-responsive data-responsive-debug src="hero.jpg" srcset="hero-400.jpg 400w, hero-800.jpg 800w, hero-1200.jpg 1200w" alt="Hero image"><!-- Shows badge: "hero-800.jpg (800px)" -->
Remove the data-responsive-debug attribute for production.
The enhancement auto-sets these attributes if not already present:
| Attribute | Default | Override |
|---|---|---|
loading |
lazy |
Set loading="eager" for above-the-fold images. |
decoding |
async |
Set decoding="sync" if you need synchronous decode. |
When you already have a correct srcset but want auto-calculated sizes:
<img data-responsive src="photo.jpg" srcset="photo-sm.jpg 480w, photo-md.jpg 960w, photo-lg.jpg 1440w" alt="Photo with auto-calculated sizes">
Let the enhancement build everything from a single src:
<img data-responsive="480,960,1440" src="product.jpg" alt="Product photo">
Override loading for critical images:
<img data-responsive="640,1280,1920" src="hero.jpg" loading="eager" fetchpriority="high" alt="Hero banner">
The enhancement uses a ResizeObserver to measure the image’s rendered width in CSS pixels. As the layout changes (viewport resize, container queries), the observer updates sizes so the browser can make optimal source selections.
This replaces manually-written sizes like (max-width: 600px) 100vw, 50vw with an accurate measurement of the actual layout. The browser’s built-in sizes="auto" proposal works similarly but has limited support — this enhancement provides the same behavior in all modern browsers.