Question

I'm running a grunt task:

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

}

The files are compressed onto one file, while running the report option

options: {
    report: 'gzip'
}

I see that the files would be significantly smaller when gzipped, but the output files are not gzipped, they are the size as per the "minified" report.

So the question is, how do I configure uglify to gzip the files also. Or is this a task for a different task?

Was it helpful?

Solution

gzipping is a technique used by a webserver to pack static assets, helping to reduce the size of transmitted data by half or more. The gzip report just lets you know how much the technique will save, but it is obviously unable to compress the file beyond normal minification. This post has some further information if you're interested:

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

Personally I'd turn gzip reporting off since it doesn't perform well; perhaps only save it for when you're ready to deploy.

OTHER TIPS

You need to manually gzip files and set the response header "encode-type" to "gzip" if your hosting your files/assets on an S3. SO i need this feature as well as a grunt task to sync files or at the very least deploy files.

You can add grunt-contrib-compress to your workflow and configure your webserver to use the gzipped version. On nginx that would be turning on gzip_static

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top