How to use grunt-contrib-uuglify for gzip js files as well?

I have a task:

uglify: { options: { report: 'gzip' }, all: { expand: true, flatten: true, cwd: 'js/', src: ['*.js', '!*.min.js'], dest: 'js/min', ext: '.min.js' } } 

Files are compressed into a single file when the report option is run.

 options: { report: 'gzip' } 

I see that the files will be significantly smaller when using gzipped, but the output files are not scrambled, they are sized according to the "reduced" report.

So the question is, how do I configure uglify for gzip files. Or is it a task for another task?

+7
javascript gruntjs grunt-contrib-uglify
source share
3 answers

gzipping is the method used by the web server to pack static assets, which helps to reduce the size of the transmitted data by half or more. The gzip report just lets you know how much the technique will save, but it obviously cannot compress a file beyond the usual minimum. This post has additional information if you are interested:

http://betterexplained.com/articles/how-to-optimize-your-site-with-gzip-compression/

Personally, I would disable the gzip report since it does not work well; perhaps save it only when you are ready to deploy.

+9
source share

You need to manually gzip the files and set the response header "encode-type" to "gzip" if you host your files / assets on S3. I need this function, as well as a task to synchronize files, or at least deploy files.

+2
source share

You can add grunt-contrib-compress to your workflow and configure your web server to use the gzipped version. On nginx, which is enabled by gzip_static

+1
source share

All Articles