Brotli JavaScript Client Side Compress/Decompress

4,152 views
Skip to first unread message

Dave Brown

unread,
Oct 16, 2015, 2:23:41 PM10/16/15
to Brotli
Looking for a pure JavaScript version of Brotli to use on www.ScriptCompress.com (already has over 20 compressors). 
I need the encoder and decoders in separate functions if possible. I only have emscripten versions (bytecode from 
C++ code), the decoder is too big (half a megabyte) so it's not useful enough. Hoping for decoder under 100KB that 
I can minify/compress to less than 20KB.

I will also set it up with it's own page, here's example for Deflate: www.whak.ca/deflate.htm

Any help is appreciated :)

Evgenii Kliuchnikov

unread,
Oct 18, 2015, 8:26:01 AM10/18/15
to Brotli
Hello.

  Getting to less than 100KB without compression would be problematic, because brotli brings >100KB dictionary with it.

  I think it is possible to represent dictionary in more compact form for JS: now it is encoded as array of bytes -> 6 chars per byte; in JS we could use a single string for it.

Best regards,
  Eugene.

Dave Brown

unread,
Oct 18, 2015, 11:21:11 AM10/18/15
to Brotli
Well that makes sense why I cannot get this algorithm is a usable JavaScript format. I forgot about the dictionary I guess. Considering most JavaScripts are under 150KB, Brotli would just make them bigger by including a built in client side decompressor when compressed to self extracting JavaScript code.

Thanks for explaining, was getting a bit frustrated.
deflate.htm

Evgenii Kliuchnikov

unread,
Oct 20, 2015, 6:28:56 AM10/20/15
to Brotli
If we compress brotli dictionary with brotli (without using dictionary), then is takes less than 50.5KB = 67.3KB in base64.

By doing so we can avoid adding supplemental decompressor.

On Friday, October 16, 2015 at 8:23:41 PM UTC+2, Dave Brown wrote:

Dave Brown

unread,
Oct 20, 2015, 3:01:18 PM10/20/15
to Brotli
I need to add decompressor with compressed data (encoded base64 will be smaller than non encoded in UTF-8) for web browser to know how to extract data with JavaScript. I am talking about client side decompression, not server side.

Dominik Homberger

unread,
Jan 6, 2016, 9:29:03 PM1/6/16
to Brotli
Hi,
you can use my Brotli JavaScript Solution. :) The javascript decoder & encoder file is uncompressed/unminified ~300 kbytes in size. The dictionarys are in external files. If you upload the files to your own server it's important you upload the dictionarys files as binary and not ascii mode. In the future I seperate the javascript decoder and encoder file to two files and optimize for better minified. Because decoder is only 89 kbytes small (unminified)

Here you can test and download my version:

Regards,
Dominik

Dave Brown

unread,
Jan 7, 2016, 2:09:52 PM1/7/16
to Brotli
I have decoders for gzip, deflate and raw that are under 10KB, guessing one of them should work, shouldn't matter that they are not Brotli I am guessing as I think Brotli just squeezes another 1 or 2% out of it.

I am not interested in external files because if someone downloads the web page, it will no longer be client side as a server is required to deliver files. How can someone use this if they turned off their internet now? 
Reply all
Reply to author
Forward
0 new messages