4 ms·
My impression is that the "default" approach is not to pollyfill but proxy the calls to the main thread. They have a post about how they are (ab)using synchrono
by kevincox 4y ago
My impression is that the "default" approach is not to pollyfill but proxy the calls to the main thread. They have a post about how they are (ab)using synchronous XMLHttpRequest calls to block the worker while proxying the request to the main process with postMessage https://dev.to/adamdbradley/how-partytown-s-sync-communication-works-4244 https://dev.to/adamdbradley/how-partytown-s-sync-communicati....
I suspect that you may want to pollyfill APIs for performance but I think for many use cases just that shim to the true API should work well enough.
- earthboundkid 4y agoIt’s a truly evil genius hack. XHR has a legacy synchronous API. So what they do is make a fake window object and any time something touches it, they do an async call out to the real window, but they make it look synchronous by doing the call via XHR to itself. Such a crazy hack!