#minify #minifier #minification #html #html5

html5minify

HTML5 minifier implementation based on Servo’s html5ever

7 releases

0.3.3 May 26, 2022
0.3.2 Jan 24, 2021
0.3.1 Nov 8, 2020
0.3.0 Oct 16, 2020
0.1.0 Jul 25, 2019

#6 in #minify

Download history 57/week @ 2022-06-11 190/week @ 2022-06-18 228/week @ 2022-06-25 70/week @ 2022-07-02 56/week @ 2022-07-09 104/week @ 2022-07-16 41/week @ 2022-07-23 35/week @ 2022-07-30 53/week @ 2022-08-06 67/week @ 2022-08-13 29/week @ 2022-08-20 21/week @ 2022-08-27 24/week @ 2022-09-03 45/week @ 2022-09-10 18/week @ 2022-09-17 24/week @ 2022-09-24

114 downloads per month
Used in html5minify-cli

MIT license

32KB
650 lines

Actions Status HTML5 minify documentation

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

~2–6.5MB
~110K SLoC