This is some crazy stuff … James Long improved the performance of the browser IndexedDB by adding a SQLite layer on top of it (SQLite compiled to WASM).
https://jlongster.com/future-sql-web
SQLite automatically uses a 2MB page cache, so you might not even notice any perf problems. It will cache the results of any read requests, and evict it whenever a write happens. For the usual use case of an app where there are many reads and sometimes writes, this works very well.
If you are working with larger data, you can try to bump the page cache up. Even something like 10MB would be fine. We’re basically lazily loading a lot of the db into memory, but we let SQLite manage it so it knows when to evict.
Local databases are neat …
The repo: