# Browser / Worker Mode Slothlet runs in the browser, web workers, and Electron renderers — anywhere there is no filesystem. Because the loader cannot `readdir` an API directory or resolve `node:*` builtins, browser mode swaps two things in: a **manifest** that lists the API modules, and an **importmap** that lets the browser resolve slothlet's own modules. Both are produced at build time (or in an Electron main process) by a single helper and shipped to the page. ## Quick start ```js // build step (Node) — produces everything the browser needs import { generateBrowserAssets } from "@cldmv/slothlet/helpers/generate-manifest"; const { manifest, importmap } = await generateBrowserAssets("./src/api"); // → manifest: the API-directory listing // → importmap: { imports: { "@cldmv/slothlet": "/node_modules/@cldmv/slothlet/…", … } } ``` ```html ``` That is the whole setup. The rest of this document explains the pieces and the less-common cases. ## Why two artifacts (manifest **and** importmap) Browser mode loads two different kinds of module, resolved at two different times: - **Your API leaves** are loaded by slothlet **at runtime**. Slothlet walks the manifest and, for each entry, calls your `resolveModuleSpecifier({ path })` to turn the manifest-relative path into a URL and dynamically `import()`s it. The manifest only needs to say _which files exist_; the URL is supplied live by your resolver. - **Slothlet's own modules** (`@cldmv/slothlet`, `@cldmv/slothlet/helpers/*`, …) are static imports the browser resolves **before slothlet runs** — so they cannot route through `resolveModuleSpecifier`. They have to be declared in the page's `