express minify html 1

express minify html

 var express    = require('express');
var minifyHTML = require('express-minify-html');
var app = express();
  override:      true,
  exception_url: false,
  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!

Here is what the above code is Doing:
1. Require the express-minify-html module.
2. Create an express app.
3. Use the express-minify-html module.
4. Create a route that renders a template.
5. Render the template and send the minified output to the client.

Similar Posts