Consider using different compression (brotli)
Just wanted to let you know that brotli significantly improves compression for this usecase, probably mostly because of brotli's integrated dictionary.
For the landing page:
- Uncompressed: 3623 chars
- Your LZMA version: 2292 chars
- Brotli + Base64: 1768 chars
Declaration of independence:
- Uncompressed: 8914 chars
- Your LZMA version: 5168 chars
- Brotli + base64: 4184
A JS implementation of brotli is here.
Interesting. I'll look into it :)
The only real trade-off is the size of that dictionary - it is nearly 1MB, which becomes expensive to serve over many loads. lzma had the benefit of being small, ~10k. I'll try it as an alternate mode, though.
Looks to me like the full official decoder (js version) is only 150 kB (70kB compressed)
check out this complete example: https://gist.github.com/phiresky/ff29eeef882aaf002d7b747ec04f6113
The decoder is easy, but looks like it's harder to find a working, compact JS encoder for brotli without external dependencies.
Yeah, I'm trying to get one, but running into this bug: https://github.com/devongovett/brotli.js/issues/20
Just for fun, I compiled the Rust Brotli implementation to WebAssembly. It works pretty well, the encoder is 970kB (470kB compressed).
See here: https://phiresky.github.io/rust-brotli-wasm/brotli-wasm-bindgen/dist/example.html (code)
No idea if all browsers support webassembly yet though, and I'm too lazy to transpile it down to asm.js.