diff options
| author | HumairAK <humair88@hotmail.com> | 2016-07-27 00:18:34 +0000 |
|---|---|---|
| committer | HumairAK <humair88@hotmail.com> | 2016-07-27 00:18:34 +0000 |
| commit | 25706820837bd05cdc3b186eb1d5ebabf9688a61 (patch) | |
| tree | afbc83b902d3f0789d5174bd2e2798937ab57b26 /node_modules/express-minify-html/README.md | |
| parent | 38594fd274a4bebee75ae71dbed457b39d253cae (diff) | |
| parent | 714368c049f8749ed22c6d1d07bb3adc783dc349 (diff) | |
Merge branch 'master' of https://github.com/HumairAK/solutions_repo
Diffstat (limited to 'node_modules/express-minify-html/README.md')
| -rw-r--r-- | node_modules/express-minify-html/README.md | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/node_modules/express-minify-html/README.md b/node_modules/express-minify-html/README.md new file mode 100644 index 0000000..c479b21 --- /dev/null +++ b/node_modules/express-minify-html/README.md @@ -0,0 +1,57 @@ +# express-minify-html +Express middleware wrapper around HTML minifier + +## Description + +This express middleware simply enchances the regular 'render' method of the response object for minifying HTML. + +## Usage + +```sh +npm install --save --production express-minify-html express +``` + +```js + +var express = require('express'); +var minifyHTML = require('express-minify-html'); + +var app = express(); + +app.use(minifyHTML({ + override: true, + htmlMinifier: { + removeComments: true, + collapseWhitespace: true, + collapseBooleanAttributes: true, + removeAttributeQuotes: true, + removeEmptyAttributes: true, + minifyJS: true + } +})); + +app.get('hello', function (req, res, next) { + res.render('helloTemplate', { hello : 'world'}, function(err, html) { + // The output is minified, huzzah! + console.log(html); + res.send(html); + }) +}); + +``` +Set 'override' to false if you don't want to hijack the ordinary res.render function. This adds an additional res.renderMin function to the response object to render minimized HTML. + +The 'htmlMinifier' opts are simply passed on to the html-minifier plugin. For all the available configuration options, see [the original repo!](https://github.com/kangax/html-minifier/blob/gh-pages/README.md) + +If no callback is provided, res.render/res.renderMin sends the minified HTML to the client just as the regular +express res.render does. Otherwise, the callback is called with the error object and the minified HTML content, as +demonstrated above. + +Full examples can naturally be found under the 'examples'-folder of this repository! + +## License + +MIT © [Matti Jokitulppo](http://mattij.com) + +[](https://badge.fury.io/js/express-minify-html) +[](https://img.shields.io/npm/dm/express-minify-html.svg) |
