From cc302b5d57bb6485fe70e5ae7e0ce71b2c38988c Mon Sep 17 00:00:00 2001 From: Menci Date: Thu, 13 Dec 2018 18:23:53 +0800 Subject: [PATCH] Minify HTTP server's response HTML --- app.js | 13 +++++++++++++ package.json | 1 + 2 files changed, 14 insertions(+) diff --git a/app.js b/app.js index 2e04ea9..475d90e 100644 --- a/app.js +++ b/app.js @@ -169,6 +169,19 @@ global.syzoj = { } app.use(Session(sessionConfig)); + app.use(require('express-minify-html')({ + override: true, + htmlMinifier: { + removeComments: true, + collapseWhitespace: true, + collapseBooleanAttributes: true, + removeAttributeQuotes: true, + removeEmptyAttributes: true, + minifyJS: true, + minifyCSS: true + } + })); + app.use((req, res, next) => { res.locals.useLocalLibs = !!parseInt(req.headers['syzoj-no-cdn']); diff --git a/package.json b/package.json index d1928b3..a50ce21 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "download": "^7.1.0", "ejs": "^2.5.2", "express": "^4.14.0", + "express-minify-html": "^0.12.0", "express-session": "^1.14.1", "file-size": "^1.0.0", "fs-extra": "^7.0.1",