stefanrush / weightof.it

Compare JavaScript libraries by weight (file size)
http://weightof.it
14 stars 0 forks source link

Gzip calculation #5

Closed FagnerMartinsBrack closed 8 years ago

FagnerMartinsBrack commented 9 years ago

Hi, very interesting project.

I see that js-cookie is listed as having a gzip size of 916 bytes at http://weightof.it/category/utilities.

In the build I am using grunt-compare-size to calculate the GZipped size and it prints the following for https://github.com/js-cookie/js-cookie/commit/d9318bb5994db77c809a6b26266b1ea84a42a40f:

image

As you see it says it has 856 bytes gzipped.

Using closure compiler it shows the correct gzipped size in the "original size" section:

image

refresh-sf.com also doesn't get even close to 900 bytes:

image

Ok, but did you reduced the size recently?

As a matter of fact we did, but even then it never overflown to 900+ byte size.

Why bother?

We try to be as lightweight as possible, it is even documented that the lib is ~800 bytes gzipped. In this case I would like to make sure that the calculation is being done correctly to prevent misleading documentation in the README.md :)

How is the gzip calculation being done to show those numbers in the site?

stefanrush commented 8 years ago

Hey, I don't know how I missed this. Thanks for taking interest in the project. I'm using Zlib for compression. Relevant code is here:

https://github.com/stefanrush/weightof.it/blob/development/lib/scale.rb

I think the difference in size is due to differences in libraries and compression levels. I'm using the default compression level for Zlib (6/9), which was admittedly an oversight. What's interesting is Zlib seems to compress some of the larger libraries more than the tools you linked to. I would chalk this up to differences in compression algorithms between libraries. I may change the compression level to 9 and reweigh the database at some point.

FagnerMartinsBrack commented 8 years ago

Hi @stefanrush. It would be very useful to use some sort of "standard" GZIP algorithm that most tools also use, that would prevent this kind of problem.

stefanrush commented 8 years ago

To my knowledge zlib is the standard library for gzip compression in Ruby. Would you recommend a different library?

FagnerMartinsBrack commented 8 years ago

I don't write Ruby so I am not aware that zlib is the standard library for that language. What I mean is try to use an optimistic tool that compress better, maybe zlib 9/9 will do that, w/e.

FagnerMartinsBrack commented 8 years ago

Unfortunately I don't know a better tool other than gzip-js that I am using on js-cookie....