Wednesday, 15 March 2017

Gzip in nodeJS and in Gulp (double gzip)

I'm working on the performance of an project. It is an node application and I use the npm package 'compression' to gzip the whole app. I'm also gzipping the minified CSS using gulp-gzip.

So this is the Gzip compression in my server.js

const compression = require('compression');
app.use(compression());

And this is the part where I gzip the CSS in my gulpfile.js

    gulp.task('cssStyles', function () {
     return gulp.src(['./src/dist/css/docs.css', './src/dist/css/fonts.css'])
     .pipe(cleanCSS())
     .pipe(gzip())
     .pipe(rename("docs.min.css"))
     .pipe(gulp.dest('./src/dist/css/'));
});

When I only used the compression in server.js, the load time of the website was faster than before. But after also gzipping my CSS via Gulp, the load time was even more faster.

My question: Is it good practice to do double gzipping (in app and with gulp), and is it possible that this will cause any problems?



via Camille Sébastien

No comments:

Post a Comment