#minify #minifier #minification #html #html5

html5minify

HTML5 minifier implementation based on Servo’s html5ever

4 releases (2 breaking)

new 0.3.0 Oct 16, 2020
0.2.1 Sep 26, 2020
0.2.0 Sep 5, 2020
0.1.0 Jul 25, 2019

#46 in Build Utils


Used in html5minify-cli

MIT license

21KB
502 lines

HTML5 minify

HTML5 minifier implementation based on Servo's html5ever.

Features

  • High performance
  • Input using AsRef<[u8]> / io::Read
  • Output to Vec<u8> / io::Write

Examples

use html5minify::Minify;

// Using Minify trait on &str:
let html = "<html> \n<link href=\"test.css\">\n<h2   id=\"id_one\"    >Hello\n</h2>    \n<p>\nWorld</p>";
let minified = html.minify().expect("Failed to minify HTML");

// Using minifier with omit doctype option set:
let mut minified = vec![];

Minifier::new(&mut minified)
    .omit_doctype(true)
    .minify(&mut html.as_bytes())
    .expect("Failed to minify HTML");

lib.rs:

HTML5 markup minifier.

Dependencies

~1.2–1.6MB
~32K SLoC