Which data compression works best for compressing javascript files when downloaded from any website: brotli
or zlib
?
Asked
Active
Viewed 1,882 times
0
-
1Define "best". Most compression? Fastest compression? Least memory? Fastest decompression? Some combination of factors and constraints? – Mark Adler Jun 03 '17 at 14:59
-
I am actually new to this topic. It would be great if you could explain which library is better in terms of each factor. – Steric Jun 04 '17 at 15:55
1 Answers
3
I'll assume that by "javascript files" you mean javascript source code.
brotli (content encoding "br") is better for non-dynamic content, where you expect it to be compressed once, but transmitted and decompressed many times. That would normally be the case for javascript. The average gain is about 20% for javascript code.
Not all clients accept brotli (so far Firefox, Chrome, and Edge do). If the client doesn't accept it, then the encoding negotiation will automatically fall back to content encoding gzip (what zlib produces).

Mark Adler
- 101,978
- 13
- 118
- 158
-
Thanks a lot! :) Does this mean that brotli is better than zlib? Also, do you have any figures in terms of the factors you mentioned previously to support your answer? Or you can guide me with how can I myself measure the data and get to the conclusions. @MarkAlder – Steric Jun 05 '17 at 04:07