Mitty library lets web workers access DOM objects via proxy RPC
A developer working on browser-based projects like Fake Linux Terminal and Hacking Cafe needed a way to give web workers access to DOM objects, which are normally inaccessible from isolated worker contexts. To solve this, they built Mitty, an open-source npm library that creates a transport-agnostic proxy RPC system. Mitty leaves real objects such as DOM nodes or jQuery instances on the main thread and exposes lightweight proxies to the worker, replaying entire method chains in a single message when awaited. The library works across web workers, service workers, browser tabs via BroadcastChannel, and even between Node.js servers and browser clients. Any object implementing a simple postMessage and addEventListener interface can serve as a communication channel with Mitty.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.



Discussion (0)
Log in to join the discussion and vote.
Log in