A lightweight library to easily move functions or classes to web workers for non-blocking UI execution.
Workly is a JavaScript library that simplifies moving functions or classes to web workers, enabling background execution of CPU-intensive tasks. It solves the problem of UI blocking by offloading work to separate threads, with all calls automatically becoming asynchronous. The library provides a straightforward proxy API to wrap existing code without complex worker setup.
Frontend developers building web applications with heavy computations, animations, or data processing that risk blocking the main thread and degrading user experience.
Developers choose Workly for its extreme simplicity and tiny size—just 1kB—compared to more complex worker abstractions. It requires minimal code changes, supports both functions and classes, and integrates seamlessly with async/await, making background execution accessible without learning the full Web Workers API.
A really simple way to move a function or class to a web worker. 🏋️♀️→ 😄
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
The proxy() function wraps existing functions or classes with almost no refactoring, as shown in the busyAdd example where a blocking function is easily moved to a worker.
All calls automatically return promises, integrating perfectly with async/await, making background execution feel natural in modern JavaScript code.
At 1kB gzipped, Workly adds negligible overhead to your bundle, keeping performance impacts minimal while enabling multithreading.
You can proxy entire classes, with instances living in the worker context, allowing for object-oriented patterns in background tasks, as demonstrated with the Adder class.
Web workers cannot access the DOM, so any function needing to update the UI directly cannot be offloaded, limiting use cases for interactive applications.
Objects are serialized when passed to workers, meaning mutations in the worker don't affect the original object, which can complicate state management.
For functions with external dependencies, you must create custom worker files and manually expose them, adding setup complexity compared to inline code.