page
Lab
The demos in this lab are the same size as the pages: no frameworks, no build step for the code you are reading, and a number at the end instead of a claim. All three use what the browser already has — a canvas, typed arrays, and a selector.
A fractal, sixty-four thousand pixels#
drawing the first frame…
A frame is 64 000 escape-time loops written straight into an ImageData and
handed to the canvas in one putImageData call. The palette is arithmetic — red
i·7, green i·5, blue 160−i, black inside the set — so there is no colour
table to fetch.
The zoom button runs ninety frames of requestAnimationFrame and reports the
average frame time it measured, not a frame rate it hopes for. The number in the
line above is a real run on your machine, which is the only machine whose speed
is worth printing.
One hash, two spellings#
seeding the buffer…
FNV-1a is defined on 32-bit words, and Math.imul is exactly a 32-bit multiply
with wraparound, so the byte loop is the definition written out in the type the
engine already has. BigInt expresses the same arithmetic exactly, without the
wraparound trick, by asking for the integer type JavaScript does not have — and
paying for it on every operation in the loop.
Both spellings hash the same buffer and the line prints both digests, because a race between two functions that compute different answers measures nothing. The point is not that JavaScript is slow: the byte fold is fast. It is that one of these loops pays a type tax and the other does not.
A filter without JavaScript#
- bashwhat the host runs
- pythonbuild.py, and the link check
- javascriptthe two demos above
- comrakmarkdown to HTML, one binary
- rsynchow this page got here
- nginxno rewrite rules of mine
The whole filter is a selector. :has() asks whether the fieldset holds a
checked radio, and every card that does not match it is display: none. No
listener, no state, no render function, nothing to re-run when the page grows.
The caveat is support — :has() is Firefox 121, Safari 15.4, Chrome 105 — and
where it is missing every card stays visible, which is the version that still
works. A progressive enhancement that degrades to “everything shows” is worth
having; one that degrades to a blank box is not.
What this says about the site#
Markdown is the source, but it is not a cage: raw HTML passes through comrak
(--unsafe), so a page can hold a canvas and a fieldset when the page is about a
canvas and a fieldset. The budget still applies — this page is under 14 KiB, and
the script beside it is one file the whole site caches.
Two WebAssembly demos used to live here, a 512-byte Mandelbrot kernel and a
213-byte 64-bit fold. They are parked in stash/wasm-lab/ rather than deleted:
on the browser I read this site in they never ran, and the host answers a
.wasm request with application/octet-stream, which is not the type a module
is meant to arrive with. Neither of those is something a page on a shared host
can fix, so the lab keeps to what runs everywhere. The kernels want a server
that is mine, and that is a different project.