#minify #minify-html #html5 #html #minification #io-read #io-write

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 #minification

Download history 442/week @ 2023-12-04 177/week @ 2023-12-11 224/week @ 2023-12-18 123/week @ 2023-12-25 314/week @ 2024-01-01 592/week @ 2024-01-08 338/week @ 2024-01-15 579/week @ 2024-01-22 898/week @ 2024-01-29 879/week @ 2024-02-05 610/week @ 2024-02-12 402/week @ 2024-02-19 362/week @ 2024-02-26 398/week @ 2024-03-04 542/week @ 2024-03-11 745/week @ 2024-03-18

2,048 downloads per month
Used in html5minify-cli

MIT license

33KB
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

~1.9–8.5MB
~49K SLoC