DEV Community

Daniel Pertu
Daniel Pertu

Posted on

Not one image on our website, five phone screens drawn in HTML, and the only PNG we ship is bigger than the homepage

Fetch munchable.app and count the pictures:

bytes        98,283
<img> tags        0
<svg> tags       55
<path> tags      59
background-image  0
Enter fullscreen mode Exit fullscreen mode

There is no public/ directory in the web app, nothing imports next/image, and the only raster file in the whole repository is the social card. The app screens on the page, the ones showing a barcode being read and a verdict coming back, are HTML elements and inline SVG.

Scroll the page and you will see five of them: the hub in the hero, a result card, the label camera, menu mode, and recipes. They live in two components, 802 lines between them, and they render as part of the page rather than as assets.

Why not screenshots

The usual reason is weight, and the weight argument is real but smaller than people assume. The interesting reasons are the other four.

They cannot be out of date in the way a screenshot is. Not because they track the app automatically, which they do not, but because changing them is a code edit in the same repository and the same design tokens as the app, rather than a round trip through a simulator, a crop and an export.

They inherit the site's typography and colour. The mock uses the product's actual tokens, so a colour change lands on the page and in the fake phone at once. A screenshot would need regenerating, and the one you forget is the one on the page people see most.

They are selectable, translatable and zoomable. Set your browser to a large font and the mock reflows like a page instead of becoming a blurry rectangle.

They can be hidden from screen readers properly. This is the part I would argue hardest for. Every mock is aria-hidden, and the explanatory copy sits beside it as real prose:

function Phone({ children }: { children: ReactNode }) {
  return (
    <div className="pm" aria-hidden="true">
Enter fullscreen mode Exit fullscreen mode

35 elements on the homepage carry aria-hidden="true", nearly all of them mock chrome. A screenshot of an app screen has to be described in an alt attribute, and a good description of a screen full of interface is a paragraph nobody writes. Here, the paragraph already exists as the page copy, and the drawing beside it is correctly announced as nothing at all.

What it costs

Two honest costs, and one of them surprised me.

The first is that it is 802 lines of components whose only job is to look like something. Fake chrome, a fake barcode, fake menu art, nine small glyph functions. That is real code to maintain for a picture.

The second is in the bytes. The mocks are server components, so every string in them is paid for twice in the HTML: once as rendered markup, once in the serialised payload the client needs to hydrate. On the homepage that payload is 51,493 bytes of 98,283, which is 52.4 per cent of the page. A screenshot would be one request for one file and no HTML cost at all.

So "HTML is lighter than images" is not quite the claim to make. The claim is that this page makes zero image requests and the markup compresses well, and that the costs it does have buy the accessibility and theming behaviour above.

The copy in the mock is copy

Here is the drift risk that is not about pixels. Look at the line under the barcode in the hero:

5 of 5 free scans left this month

The app's home screen types the same sentence, from the same numbers, in a different repository package:

{remaining} of {FREE_SCAN_LIMIT} free scans left this month ยท
Enter fullscreen mode Exit fullscreen mode

Two independent copies of a product sentence, one of which is a hard-coded "5 of 5" on a marketing page. If the free allowance changed and nobody searched the website for it, the mock would keep advertising the old number in a screen that looks like a real screenshot. Nothing in a test catches that today, which I am writing down here because it is the kind of thing a public note turns into a fix. The number itself, and why it is counted where it is, is the subject of an earlier post about the quota.

Same story for the verdict words in the mock. They are the product's three answers, typed on a page that cannot read them from the engine.

The one image we do ship

apps/web/app/opengraph-image.png      122,886 bytes
apps/web/app/opengraph-image.alt.txt      "The Munchable cookie logo beside the
                                           words Trust your gut again."
Enter fullscreen mode Exit fullscreen mode

One PNG, 122,886 bytes, which is larger than the entire HTML of the homepage it advertises. It never appears on any page. Its only job is to be the card that social platforms and chat apps show when somebody pastes a link, which is the one context where markup is not an option and a file is the only thing that works.

It used to be generated per page at the edge, and it is now a static file, which is the trade you make once you accept that every link to the site can share the same card.

See it yourself

The mocks are on the homepage, and the easiest way to prove they are not pictures is to select the text inside one of the fake phones and copy it. The recipes mock is a drawing of munchable.app/recipes, which is a real page you can open, and the conditions those mock verdicts refer to are each written up at munchable.app/conditions.

Top comments (0)