#minify-html #html #minification #json

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

#135 in Compression

Download history 248/week @ 2023-12-18 451/week @ 2023-12-25 356/week @ 2024-01-01 396/week @ 2024-01-08 582/week @ 2024-01-15 613/week @ 2024-01-22 412/week @ 2024-01-29 440/week @ 2024-02-05 598/week @ 2024-02-12 735/week @ 2024-02-19 629/week @ 2024-02-26 538/week @ 2024-03-04 725/week @ 2024-03-11 934/week @ 2024-03-18 1054/week @ 2024-03-25 1243/week @ 2024-04-01

3,980 downloads per month
Used in 5 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