Move an async function into its own Web Worker thread for off‑main‑thread execution.
Greenlet is a tiny JavaScript library that lets you move any async function into a Web Worker thread with a single function call. It solves the problem of blocking the main thread during CPU‑intensive or long‑running tasks by automatically offloading the function execution to a background worker, while keeping the API as simple as calling the original function.
Frontend developers who need to run CPU‑heavy calculations, data processing, or network requests without blocking the UI, and want a dead‑simple way to use Web Workers without manual setup.
Developers choose Greenlet because it removes all the complexity of Web Workers—no message‑passing boilerplate, no separate worker files—and delivers the same performance as hand‑rolled Workers, all in under 1 KB.
🦎 Move an async function into its own thread.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Just pass an async function to greenlet() to get a workerized version, eliminating all Web Worker boilerplate and configuration.
Automatically handles transferable objects like ArrayBuffers for zero-copy performance, reducing memory overhead during data exchange.
Gzipped size is under 1 KB, making it negligible in bundle impact and ideal for performance-conscious web apps.
Works in IE10+ and all modern browsers with Web Workers, ensuring broad compatibility without polyfills in browsers.
Functions cannot access closure variables, forcing all dependencies to be passed explicitly, which complicates code that relies on lexical scope.
Creating greenlets dynamically spawns new Workers each time, leading to performance degradation and resource leaks if not carefully managed, as warned in the README.
Requires specific Content-Security-Policy settings (worker-src blob: and script-src blob:), adding complexity in strict security environments.