Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider using different compression (brotli) #10

Open
phiresky opened this issue Jul 6, 2018 · 6 comments
Open

Consider using different compression (brotli) #10

phiresky opened this issue Jul 6, 2018 · 6 comments

Comments

@phiresky
Copy link

phiresky commented Jul 6, 2018

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.

@alcor
Copy link
Member

alcor commented Jul 6, 2018

Interesting. I'll look into it :)

@alcor
Copy link
Member

alcor commented Jul 6, 2018

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.

@phiresky
Copy link
Author

phiresky commented Jul 6, 2018

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

@phiresky
Copy link
Author

phiresky commented Jul 6, 2018

The decoder is easy, but looks like it's harder to find a working, compact JS encoder for brotli without external dependencies.

@alcor
Copy link
Member

alcor commented Jul 6, 2018

Yeah, I'm trying to get one, but running into this bug: foliojs/brotli.js#20

@phiresky
Copy link
Author

phiresky commented Jul 6, 2018

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.

@alcor alcor added this to the post-validation milestone Jul 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants