A collection of speedy minifiers written in PHP with linear space and time complexity for HTML, JavaScript, and CSS.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
benchmark resources
lib
spec
.gitignore
LICENSE
NOTICE
README.md
benchmarks.js
index.js
package.json

README.md

Overview

A collection of speedy minifiers for HTML, JavaScript, and CSS.

This library is inspired by Jonathan Walsh's CSSFastMin, of which my CSS minifier is a port with some modifications of my own.

Usage

Node

const FastMin = require( 'FastMin' );

const CSS = "body { font: bold 14px Helvetica; }";

let minifiedCSS = FastMin.CSS( CSS );

FastMin also provides each minifier as a transform stream. Both are available via the FastMin module:

const http = require( 'http' );
const fs = require( 'fs' );

http.createServer( function ( req, res ) {
  res.writeHead( 200, { 'Content-Type': 'text/html' } );
  
  const HTMLMinifier = new FastMin.stream.HTML();            // Minifier stream
  const HTMLStream = fs.createReadStream( 'index.html' );    // HTML file stream
  
  // Pipe the file through the minifier and then to the client
  HTMLStream.pipe( HTMLMinifier ).pipe( res );
} ).listen( 8888 );