Socket
Socket
Sign inDemoInstall

minify-html-stream

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

minify-html-stream

A streaming HTML minifier for Node.js


Version published
Weekly downloads
1
decreased by-97.96%
Maintainers
2
Weekly downloads
 
Created
Source

Build Status Coverage Status

Minify HTML Stream

Strips whitespace from an HTML stream to reduce the size of the final payload.

Install

Install with npm

npm install --save minify-html-stream

Simple Example

"use strict";

const fetch = require("node-fetch");
const Minifier = require("minify-html-stream").Minifier;

fetch("http://example.com/").then(function (response) {
    response.body.pipe(new Minifier()).pipe(process.stdout);
}).catch(function (err) {
    console.error("Yikes!", err);
});

How You Might Use It

"use strict";

// Declare variables
const http = require("http");
const talisman = require("talismanjs");
const Minifier = require("minify-html-stream").Minifier;

// Start a server
const server = http.createServer(function (request, response) {
    talisman.create("homepage.html").then(function (view) {
        view.toStream().pipe(new Minifier()).pipe(response);
    }).catch(function (error) {
        response.writeHead(500);
        response.write(error.message);
        response.end();
    });
});

// Start listening
server.listen(8000);

Configuration

{
    stripCarriageReturns: true, // remove carriage return characters (\r)
    trimLines: true, // remove whitespace from the ends of lines
    trimElements: true, // remove whitespace from around elements where it is safe
    normalizeWhiteSpace: true, // normalize multiple whitespace characters to single characters
    stripComments: true // remove HTML comments (except conditional comments)
}

Notes

Minify HTML Stream is really naïve and conservative about how it goes about minification, because it sort of has to be. Pull requests are most welcome.

Published under the MIT License.

Keywords

FAQs

Package last updated on 04 Jul 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc