Who it is forA developer shipping a multi page app or PWA with local AI.
The problemReloading a multi gigabyte model on each page view is slow.
The outcomeA service worker engine shared across pages, with model files cached in the browser.
What you need first
- A browser with WebGPU support on a device with a capable GPU
- Node with npm, yarn or pnpm: `npm install @mlc-ai/web-llm`, or import from the jsdelivr CDN
- Bandwidth and storage for the first model download, which the README warns can take a significant amount of time
Steps
- Install with
npm install @mlc-ai/web-llm - In sw.ts instantiate ServiceWorkerMLCEngineHandler at the top level of the script
- Register the service worker in main.ts and create the engine with CreateServiceWorkerMLCEngine
- Optionally set AppConfig.cacheBackend to cache, indexeddb or opfs
Prompt for your agent
Using mlc-ai/web-llm, add a sw.ts with ServiceWorkerMLCEngineHandler, register it, create the engine with CreateServiceWorkerMLCEngine, and set cacheBackend to indexeddb.
Caveat. The README warns the browser can kill a service worker at any time, so add error handling.
Use this in your AI agent
Ask your agent
Using the Deduped MCP, get the setup steps for mlc-ai/web-llm and "Keep the model loaded across page visits"
Add Deduped to Claude Code once
claude mcp add --transport http deduped https://dedupedai.com/mcp
Every Monday: the 5 hottest repos and exactly how to use them. Free, one email a week, unsubscribe anytime.
Get them freeShare: X LinkedIn Hacker News Email Copy link
Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer