The Workbench · The Shelf

A client-side search has to ship its own index

Search looks like the one feature a browser-only tool can't have. Type a term, get a result, and somewhere behind that exchange most people assume a server: a query goes out, a database gets scanned, a ranked list comes back. A tool that runs entirely in the tab, with nothing to call home to, doesn't have that server — which looks like a dead end until the actual requirement gets restated correctly. Search doesn't need a live database behind it. It needs an index, and an index is just a file. Build it once, ship it alongside the page, and the browser can search it without asking anyone else's computer for help.

The thing search needs isn't a server; it's a precomputed answer

A server-backed search engine does two jobs that look like one: it holds the content, and it answers queries against an index built from that content. The index is the part that actually answers the question; the server is just where that index happened to live. Separate the two and the server stops being load-bearing. A static site can hold its content as plain pages and still ship a separate, precomputed index file — titles, headings, the specific CFR section or ISO clause each page maps to — and let a few lines of JavaScript running in the visitor's own browser match a typed query against that file. Nothing calls out anywhere. The search runs on hardware the visitor already brought.

The index has to be built with the content, not after it

An index maintained by hand, separately from the pages it describes, goes stale the exact way a template goes stale when its source moves and nobody updates the copy downstream — except a stale index doesn't announce itself as an obviously wrong citation. It just quietly stops returning a page that still exists, or keeps returning one that's been retired, and a visitor who searched and found nothing has no way to know whether the gap is in the content or in the index. The fix is the same discipline this blog has argued for in the content itself: generate the index from the same source, at the same build step, that generates the pages. An index that's a byproduct of publishing can't drift from what it's indexing. One maintained as a separate chore eventually will.

Size is the real constraint, not cleverness

A browser has no server-side compute budget to borrow against, which means the index shipped to it has to stay small enough to download as an ordinary static asset and fast enough to scan on whatever device opened the tab — a phone on a slow connection, not just a desktop on fiber. That's a budget, not a technology choice: a flat index of titles, headings, and a handful of indexed terms per page, matched with straightforward keyword scoring, covers a library of dozens to low hundreds of documents without strain. The temptation to reach for something more sophisticated — fuzzy matching, relevance ranking tuned like a real search engine — is usually solving a problem a catalog this size doesn't have yet, at the cost of exactly the simplicity that let it run without a server in the first place.

Why this isn't just a performance detail

Reaching for a hosted search service the moment a static index feels limiting would reintroduce the dependency the rest of the architecture was built to avoid. This blog has already made the broader case that running entirely in the tab is a structural commitment, not a tagline — the same reasoning that keeps a tool's output leaving the tab as a download instead of a submission applies just as directly to the query a visitor types to find that tool in the first place. A search box that quietly phones a third-party service has handed that service every term a visitor searches for, which is a worse privacy posture than the tool it's attached to, for a feature that a static file could have handled with nothing leaving the browser at all.

What this means for a shelf full of citations

A catalog organized around source-mapped templates and checklists has an unusually good reason to make search work this way: the thing a visitor is actually searching for is often a citation — a CFR section, an ISO clause, a form number — not a page title, and that only works if the index was built to carry those terms in the first place rather than guessing at them after the fact. A search index generated at build time from the same citations this shelf already tracks, shipped as a flat file and matched entirely client-side, is part of what's previewed at the library. If your own catalog has outgrown a flat index before reaching a server, the shelf takes that experience directly.

The Regulatory Toolkit launches soon — a free shelf of source-mapped templates, checklists and browser-only tools for regulatory teams. Get one email when it opens, or contribute a template.

All Workbench notes