Originally I had it going via browser -> postmessage -> zig -> bun via named pipes and then bun -> zig via named pipe -> js via evaluate js.
I’m building https://colab.sh/ with electrobun and that rpc was pretty slow when trying to load multi MB files in the code editor.
Last week I added an encrypted socket rpc option directly between bun and browser.
Loading a 2MB file went from a few seconds to 400ms.
I made it so that in contexts where CORS allows it automatically upgrades to the socket based faster RPC.
That’s via RPC though. electrobun also exposes a custom views:// scheme in the browser context that can load files directly from specific sandboxed places in the file system. More to improve there but for a very big file you’d be better off writing it to the file system that would be much faster.