Thursday, June 6, 2024
 Popular · Latest · Hot · Upcoming
8
rated 0 times [  11] [ 3]  / answers: 1 / hits: 56352  / 13 Years ago, mon, february 27, 2012, 12:00:00

How can I estimate the size of my JavaScript file after it is gzipped? Are there online tools for this? Or is it similar to using winzip for example?


More From » gzip

 Answers
8

http://closure-compiler.appspot.com/home lets you paste in code, and it will give you compression ratios for a particular file before and after GZIP.




Original Size:    90 bytes (100 bytes gzipped)
Compiled Size: 55 bytes (68 bytes gzipped)
Saved 38.89% off the original size (32.00% off the gzipped size)



You can use the pretty-print and white-space only options to estimate the compression of non-minified content.



If you need an estimate:




  • Start with 100 JS files that have gone through the same minification pipeline.

  • For each file, compute the ratio in sizes between gzip -c $f | wc -c and wc -c $f

  • The average of those ratios is an approximation of the compression you should expect for a similar JS file.



Cygwin contains command line implementations of gzip and wc for Windows.


[#87181] Saturday, February 25, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
seth

Total Points: 307
Total Questions: 114
Total Answers: 96

Location: Kenya
Member since Mon, Jun 14, 2021
3 Years ago
seth questions
Tue, Feb 8, 22, 00:00, 2 Years ago
Thu, Dec 24, 20, 00:00, 4 Years ago
Sun, Apr 19, 20, 00:00, 4 Years ago
Thu, Apr 9, 20, 00:00, 4 Years ago
;