#minify-html #minification #html #json #json-text

minify

Crate for text minification. Currently supported: html, json

5 stable releases

1.3.0 Dec 4, 2021
1.2.0 Nov 16, 2020
1.1.1 Jul 1, 2018
1.0.0 Jul 1, 2018

#179 in Compression

Download history 494/week @ 2024-07-23 303/week @ 2024-07-30 185/week @ 2024-08-06 266/week @ 2024-08-13 290/week @ 2024-08-20 227/week @ 2024-08-27 277/week @ 2024-09-03 191/week @ 2024-09-10 134/week @ 2024-09-17 183/week @ 2024-09-24 207/week @ 2024-10-01 128/week @ 2024-10-08 146/week @ 2024-10-15 160/week @ 2024-10-22 175/week @ 2024-10-29 168/week @ 2024-11-05

674 downloads per month
Used in 6 crates

MIT license

29KB
788 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>
    "#;
    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
           }
       "#;
    let json_minified = minify(json);
}

License: MIT

No runtime deps