#minify #minification #html #json

minify

Crate for text minification. Currently supported: html, json

4 stable releases

1.2.0 Nov 16, 2020
1.1.1 Jul 1, 2018
1.0.0 Jul 1, 2018

#36 in Compression

Download history 4/week @ 2020-08-02 25/week @ 2020-08-09 8/week @ 2020-08-16 130/week @ 2020-08-23 107/week @ 2020-08-30 54/week @ 2020-09-06 88/week @ 2020-09-13 222/week @ 2020-09-20 84/week @ 2020-09-27 146/week @ 2020-10-04 167/week @ 2020-10-11 345/week @ 2020-10-18 179/week @ 2020-10-25 164/week @ 2020-11-01 201/week @ 2020-11-08 275/week @ 2020-11-15

644 downloads per month
Used in snekdown

MIT license

27KB
747 lines

minify

Minification tool for html and json

Usage

First add the library to the dependencies of your project like this:

[dependencies]
minify = "1.2"

Afterwards you can import the library like this:

extern crate minify;

Minify Html

The following rules are applied for html minification:

  • Removal of ascii control characters
  • Removal of comments
  • Removal of multiple whitespaces
  • Removal of whitespaces before and after greater-than and less-than signs
    • _<_html_>_ => <html>
extern crate minify;
use minify::html::minify;

fn main() {
    let html = r#"
        <html>
            <head>
            </head>
            <body>
            </body>
        <html>
    "#.into();
    let html_minified = minify(html);
}

Minify JSON

The following rules are applied for json minification:

  • Removal of ascii control characters
  • Removal of whitespaces outside of strings
extern crate minify;
use minify::json::minify;

fn main() {
    let json = r#"
           {
               "test": "test",
               "test2": 2
           }
       "#.into();
    let json_minified = minify(json);
}

License: MIT

No runtime deps