I am new to NodeJS, Express
and templates
I am trying to generate a table and send the output to user and it is working
fine using EJS
but the html generated has lots of whitespace.
So when a size of generated html file is around 148kb
after using online html compressor then size becomes 38kb
So how do i compress html after rendering and send it to user.
is there a build-in method in express or ejs
I know that pug already generates compressed html but i want to use EJS
CodePudding user response:
there's no built in method, try express-minify-html
const express = require('express');
const minifyHTML = require('express-minify-html');
const app = express();
app.use(minifyHTML({
override: true,
exception_url: false,
htmlMinifier: {
removeComments: true,
collapseWhitespace: true,
collapseBooleanAttributes: true,
removeAttributeQuotes: true,
removeEmptyAttributes: true,
minifyJS: true
}
}));