pagefind
pagefind copied to clipboard
Fallback for when WebAssembly is not available
WebAssembly is not available when browsers disable JIT compilation:
- Edge's enhanced security mode
- The Tor Browser's "safer" security level
- iOS Lockdown mode
- Vanadium and Bromite are hardened Android browsers that support per-site JIT toggles.
I'm sure more examples exist. Some of these, such as iOS Lockdown and Edge's Enhanced Security, are relatively recent developments, so it's not unreasonable to assume that the popularity of JIT-toggling will increase with time.
A good approach would be to have an asm.js-based fallback. That's the approach used by CryptPad, and it has good results. Some polyfills allow transpiling WebAssembly to asm.js with usable performance.
This is a good idea, and the concept of transpiling the WebAssembly is especially great as it reduces any maintenance burden in having both implementations. I haven't experimented with any transpilers, but Pagefind's WebAssembly is intentionally simple and small, so if anything would work through that process it would be this.
I'm unlikely to have the time to tackle this in the medium-term, but I'm open to someone contributing this as a feature. Ping me in this thread if anybody wants to spitball what might be needed for them to implement this 🙂
polywasm works fine with pagefind. tl;dr
self.WebAssembly = self.WebAssembly || (await import("https://unpkg.com/[email protected]/index.min.js")).WebAssembly
I just ran into this issue with chromite and vanadium. I posted about it here but will remove it now.
polywasm works fine with pagefind.
Impressive! Thanks for the pointer. I'll take it for a spin and then look at adding this as an official fallback.