Skip to content

Visibility Pause ​

Pause expensive work when the document is hidden.

Import path ​

ts
import { createBrowserLifecycle } from "@jayoncode/browser-lifecycle";

Single package entry. Dispose the session when the shell unmounts.

Implementation ​

ts
const lifecycle = createBrowserLifecycle({ autoStart: true });

lifecycle.on("page:hidden", () => worker.pause());
lifecycle.on("page:visible", () => worker.resume());

// later
lifecycle.dispose();

Performance ​

Reduces CPU, network, and battery use for background tabs.

Playground ​

Visibility Playground

An ecosystem of independent, headless TypeScript libraries engineered for modern web development. Every package includes interactive playgrounds and documentation that evolves alongside the code.