Can I use GZIP compression on files that have been minified by Gulp or Grunt? I wonder if there is a possibility that I have problems with that. Or if I would have an even faster loading on the browser side.
Can I use GZIP compression on files that have been minified by Gulp or Grunt? I wonder if there is a possibility that I have problems with that. Or if I would have an even faster loading on the browser side.
Yes, it is a good idea to minify your files .js
and .css
and then compress them using gzip
.
I did a simple test with jQuery . I downloaded the undiminished jQuery and the minified jQuery:
-rw-rw-r-- 1 user group 258648 Mar 17 23:32 jquery-2.2.2.js
-rw-rw-r-- 1 user group 85656 Mar 17 23:32 jquery-2.2.2.min.js
Notice that undiminished jQuery has 258 Kb
and minified 85 Kb
.
And after that I compressed the two files using the command gzip -9
( -9
represents the slowest and most effective compression):
-rw-rw-r-- 1 user group 76515 Mar 17 23:32 jquery-2.2.2.js.gz
-rw-rw-r-- 1 user group 29763 Mar 17 23:32 jquery-2.2.2.min.js.gz
The jQuery-only compressed file has 76 Kb
, while jQuery and compressed has 29 Kb
.
And since you're already using Grunt
, take a look at grunt-contrib-compress
to automate the compression of the files.