如何在 expressJS 框架中压缩 EJS 输出?
How to compress EJS output in expressJS framework?
我是 NodeJS, Express
和 模板的新手
我正在尝试生成一个 table 并将输出发送给用户并且它正在运行
使用 EJS
很好,但是生成的 html 有很多空格。
因此,当使用在线 html 压缩器后生成的 html 文件大小约为 148kb
时,大小变为 38kb
那么如何在渲染后压缩 html 并将其发送给用户。
express 或 ejs 中是否有内置方法
我知道哈巴狗已经生成压缩包 html 但我想使用 EJS
没有内置方法,试试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
}
}));
我是 NodeJS, Express
和 模板的新手
我正在尝试生成一个 table 并将输出发送给用户并且它正在运行
使用 EJS
很好,但是生成的 html 有很多空格。
因此,当使用在线 html 压缩器后生成的 html 文件大小约为 148kb
时,大小变为 38kb
那么如何在渲染后压缩 html 并将其发送给用户。
express 或 ejs 中是否有内置方法
我知道哈巴狗已经生成压缩包 html 但我想使用 EJS
没有内置方法,试试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
}
}));