pagefind icon indicating copy to clipboard operation
pagefind copied to clipboard

Fallback for when WebAssembly is not available

Open Seirdy opened this issue 11 months ago • 4 comments

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.

Seirdy avatar Jul 23 '23 01:07 Seirdy

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 🙂

bglw avatar Jul 23 '23 02:07 bglw

polywasm works fine with pagefind. tl;dr

self.WebAssembly = self.WebAssembly || (await import("https://unpkg.com/[email protected]/index.min.js")).WebAssembly

easrng avatar Jan 12 '24 02:01 easrng

I just ran into this issue with chromite and vanadium. I posted about it here but will remove it now.

demosthenez avatar Feb 03 '24 19:02 demosthenez

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.

bglw avatar Feb 04 '24 22:02 bglw