我是新手NodeJS, Express和模板
我正在嘗試生成一個表并將輸出發送給用戶,它作業正常,EJS但生成的 html 有很多空格。
148kb因此,當使用在線 html 壓縮器后生成的 html 檔案大小大約為38kb
那么如何在渲染后壓縮html并將其發送給用戶。
express 或 ejs 中是否有內置方法
我知道哈巴狗已經生成了壓縮的 html,但我想使用 EJS
uj5u.com熱心網友回復:
沒有內置方法,試試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
}
}));
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/411359.html
標籤:
