HTML Minifier

Build Status

This tool can help you generate and minify your HTML code at the same time. It also supports to minify JS and CSS in <style>, <script> elements, and ignores the minification of <pre> elements.

HTML is minified by the following rules:

You should notice that the HTML code is generated and minified simultaneously, which means you don't need an extra space to store you original HTML source.

Examples

```rust extern crate html_minifier;

use html_minifier::HTMLMinifier;

let mut html_minifier = HTMLMinifier::new();

html_minifier.digest(r#" < head> 123456 big 789

                <  /body>
            </  html>
    "#).unwrap();

asserteq!(r#"123456 big 789"#, htmlminifier.get_html()); ```

```rust extern crate html_minifier;

use html_minifier::HTMLMinifier;

let mut html_minifier = HTMLMinifier::new();

html_minifier.digest(r#"

        1234567
    
1234567
        1234567
    
"#).unwrap();

asserteq!(r#"

    
        1234567
    
1234567
        1234567
    
"#, htmlminifier.get_html()); ```

```rust extern crate html_minifier;

use html_minifier::HTMLMinifier;

let mut html_minifier = HTMLMinifier::new();

html_minifier.digest(r#"", htmlminifier.get_html()); ```

```rust extern crate html_minifier;

use html_minifier::HTMLMinifier;

let mut html_minifier = HTMLMinifier::new();

html_minifier.digest(r#""#).unwrap();

asserteq!("", htmlminifier.get_html()); ```

Crates.io

https://crates.io/crates/html-minifier

Documentation

https://docs.rs/html-minifier

License

MIT