Comlink Makes WebWorkers Enjoyable
npmjs.com
npmjs.com
IndexedDB can be shared amongst Web Workers for the same origin (localStorage cannot).
https://dexie.org is a nice IndexedDB library.
As an example, if you have many web workers, each can write their current state or use transactions to take items from a queue, and a central UI can just query the single IndexedDB.
I quite like IndexedDB as it is widely supported by browsers.
Although for simple data I prefer the sync localStorage API.
Comlink gives a seamless abstraction over the worker "bridge", and Dexie does the same for the complex IDB API.
I have run into performance issues with Dexie when querying lots of objects (~1M) from a collection, but it looks like it's more of a limitation on IndexedDB itself.
Example of using here https://github.com/mrloop/activity-merge/blob/main/app/contr...
The lib author wrote a nice blog post about "why webworkers" and "why comlink" a few years ago: https://surma.dev/things/when-workers/
They're basically the future of any serious web first PWA where you're not even concerned about a server doing anything.
Look into quickjs if you want untrusted JavaScript in the browser.
A quick read suggests it's note wiring iframe comes which requires another abstractions.
Anyway from a quick read I saw that plenty people use comlink with iframes, thanks though
const instance = await new MyClass();