📚 Encyclopedia

Web Development · updated 2026-10-13

Offline-first browser tools (module workers, precache lists, no build step)

web-workersservice-workerofflinees-modulespwaarchitecture

A pattern for heavy, privacy-friendly web tools that do everything client-side (nothing uploaded) and keep working offline, as built for cncfileoptimizer.com (2026-09/10): static ES modules with no framework, no build step and no CDN; a module Web Worker for computation; a service worker for offline.

Layering

Worker protocol

Service worker and precache

Handing data between pages

Two entry pages shared work through sessionStorage ({kind, name, text} or base64 for binary), read once by the receiving page. Versioned localStorage keys (app.settings.stl.v2) let defaults change without stale saved values overriding them.

Durable browser state (agreed design for a game save system)

For saves that must survive, the plan agreed for Spacebar's JS rebuild: IndexedDB as the main store, a synchronous localStorage "panic write" on pagehide/visibilitychange for the latest state, a navigator.storage.persist() request so the browser does not evict the data under storage pressure, and a schema version with explicit migrations from day one.

Deploy verification

The deploy script backs up the old docroot, rsync --deletes the app, then curls every file and checks both the 200 status and the MIME type (a JS module served with the wrong type fails silently in the browser). On an older Apache: a global Alias /icons/ hijacks app icons, so ship them under assets/, and .webmanifest had no MIME type, so the manifest was named manifest.json (Apache vhost gotchas (icons alias, manifests, SPA fallback, redirects)).

Testing

Node unit tests for the engine (144 tests, about 70 s), an e2e smoke test in headless Chrome via playwright-core pointed at the system Chrome, runnable against local or live with a BASE_URL variable, including 390 px screenshots (Headless Chrome testing gotchas).

See also

Linked from

Sources: spacebar memory (project_js_rebuild), cnc memory (MEMORY.md, architecture.md, pending.md), tldr posts #1662, #1745