We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
执行命令下载包 npm install compression --save-dev
npm install compression --save-dev
加载包
compression = require('compression'); app.use(compression());
整体代码
var express = require('express'), app = express(), path = require('path'), compression = require('compression'); app.use(compression()); app.set( 'view engine', 'html' ); app.engine( '.html', require( 'ejs' ).__express ); app.set('views', path.join(__dirname, '/app/views')); app.use(express.static(path.join(__dirname, '/public'))); require('./app/routes/index')(app);
压缩前:
Name Status Type Initiator Size Time static.js 200 script (index):2 135 KB 16 ms vendors.js 200 script (index):2 250 KB 18 ms client.js 200 script (index):2 111 KB 18 ms login.e8c9aed7.js 200 script static.js:1 6.5 KB 3 ms
压缩后:
Name Status Type Initiator Size Time static.js 200 script (index):2 46.1 KB 16 ms vendors.js 200 script (index):2 67.9 KB 18 ms client.js 200 script (index):2 29.9 KB 18 ms login.e8c9aed7.js 200 script static.js:1 2.0 KB 3 ms
执行命令下载包 npm install koa-gzip --save-dev
npm install koa-gzip --save-dev
var gzip = require('koa-gzip'); app.use(gzip());
具体代码同上
单独node.js压缩方法
node.js
The text was updated successfully, but these errors were encountered:
No branches or pull requests
node.js + express
执行命令下载包
npm install compression --save-dev
加载包
整体代码
压缩前:
压缩后:
node.js + koa
执行命令下载包
npm install koa-gzip --save-dev
加载包
具体代码同上
单独
node.js
压缩方法The text was updated successfully, but these errors were encountered: