WordPress / wordpress-playground

Run WordPress in the browser via WebAssembly PHP
https://w.org/playground/
GNU General Public License v2.0
1.61k stars 240 forks source link

Run the same WordPress instance across many browser tabs #32

Open adamziel opened 1 year ago

adamziel commented 1 year ago

Browsing the same WordPress instance in multiple browser tabs could be useful. Props to @gziolo for the idea.

Technically, it would take:

eliot-akira commented 2 months ago

A recent article describes how Notion used SharedWorker to share an SQLite database in OPFS across multiple browser tabs.

To execute any SQLite query, the main thread of each tab sends that query to the SharedWorker, which redirects to the active tab’s dedicated Worker. Any number of tabs can make simultaneous SQLite queries as many times as they want, and it will always be routed to the single active tab.

How we sped up Notion in the browser with WASM SQLite

notion shared-worker architecture for sqlite-wasm in multiple tabs


The idea was earlier explored in detail in wa-sqlite.

It's basically how you imagined in this comment.

Another option would be to use SharedWorker as a traffic controller that elects one of the active tabs as a "leader" and uses it to resolve all the requests.