Plate № 49 · UX primitives · time

A pattern from the gf.cx specimen book

Count it in the browser, not the build

Some numbers drift with time: “742 days and counting”, a running tally. Don’t bake them into the HTML and schedule a job to bump them. Store the fixed anchor date, day 0, and let the browser work out the count each time the page is read.

The move

<span data-days-since="2024-09-15">742 days</span>
<script src="https://assets.gf.cx/days-since/days-since.js" defer></script>

The anchor is day 0, and the count is full days elapsed: floor((now − day0) / 86,400,000). It isn’t an inclusive count, so the day of the event itself is 0, not 1. The text inside the span is the no-JS fallback. With JS on it’s overwritten on load, so it only needs to be roughly right.

Live, from a fixed anchor of 15 Sep 2024

742 days · 106 weeks · 24 months · 2 years

One anchor, four readings. data-unit varies how the page says the same span of time instead of repeating the day count.

AttributeValuesDefault
data-days-sinceYYYY-MM-DD, read as local midnightrequired
data-unitdays · weeks · months · yearsdays

A bad or future anchor leaves the fallback untouched. Nodes added after load are picked up by a MutationObserver, so a counter still works inside markup another script clones in, such as an extra row in the built-with provenance footer. window.DaysSince.refresh(el) forces a re-render.

Why not a republish cron

The first instinct is a script that captures the date and a scheduled rebuild that refreshes the number. But that’s an unattended job, and under the ops baseline an unattended job needs a preflight, a second runner, a status line and a stale-green guard, all to increment an integer. Worse, it adds the failure it was meant to prevent: a missed run leaves a wrong number on the page while everything still reports green. Computing at read time has no run to miss.

This isn’t antifragile, just robust: it removes a way to fail rather than getting stronger under stress. What it does is remove the coupling (current number ↔ scheduled rebuild) instead of hardening the component, which is field note № 1 at antifragile.gf.cx.

Two kinds of number

KindExampleTreatment
Live total“742 and counting”data-days-since
Fixed marker“over 500 days until she returned”hard-coded, always

Making a fixed marker dynamic rewrites history without anyone noticing. Keep past facts fixed and make only the running total live.

When the number must be in the bytes

An og:image headline, a crawler or a screenshot can’t run the script. Even then, don’t add a per-page cron. Add a data-days-since pass to the shared build tooling so every surface gets it at once (see edit the generator, not its output).

Related

Human-friendly relative time formats an event’s timestamp (“3d ago”). days-since counts a running span from a chosen origin. The shelf’s date-counter looks forward to a deadline, and maintenance-timer counts down a recurring interval.

First used on happiness.gf.cx · the 1am paragraph for the no-contact count (inline from 2026-07-07, moved to the shelf on 2026-09-27, and now also shown in that page’s “Built with” footer).