# minify-html-stream

> A streaming HTML minifier for Node.js

Latest version **0.3.1** (published 2016-07-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install minify-html-stream
pnpm add minify-html-stream
yarn add minify-html-stream
bun add minify-html-stream
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.1 |
| Published | 2016-07-04 |
| First published | 2016-04-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.0 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Digital Design Labs |
| Maintainers | digitaldesignlabs, mikehall314 |
| Keywords | minify, html, stream, transform, minifier |

## Links

- npm: https://www.npmjs.com/package/minify-html-stream
- Repository: https://github.com/digitaldesignlabs/minify-html-stream
- Homepage: https://github.com/digitaldesignlabs/minify-html-stream#readme
- Issues: https://github.com/digitaldesignlabs/minify-html-stream/issues
- npm.io page: https://npm.io/package/minify-html-stream

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 0.3.1 (latest) — 2016-07-04
- 0.3.0 — 2016-07-01
- 0.2.0 — 2016-06-24
- 0.1.1 — 2016-04-27
- 0.1.0 — 2016-04-27

## README

[![Build Status](https://travis-ci.org/digitaldesignlabs/minify-html-stream.svg?branch=master)](https://travis-ci.org/digitaldesignlabs/minify-html-stream)
[![Coverage Status](https://coveralls.io/repos/github/digitaldesignlabs/minify-html-stream/badge.svg?branch=master)](https://coveralls.io/github/digitaldesignlabs/minify-html-stream)

# Minify HTML Stream

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

## Install

Install with [npm](https://www.npmjs.com/package/minify-html-stream)

```bash
npm install --save minify-html-stream
```

## Simple Example

```js
"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
```js
"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
```js
{
    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](http://opensource.org/licenses/MIT).

---
_Source: https://npm.io/package/minify-html-stream · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
