Skip to main content

minify_html_string

Function minify_html_string 

Source
pub fn minify_html_string(html: &str) -> Result<String>
Expand description

Minifies an HTML string in memory.

Applies the same minification rules as minify_html() but operates on an in-memory string instead of a file path.

§Arguments

  • html - The HTML content to minify

§Returns

Returns the minified HTML content as a string if successful.

§Errors

Returns HtmlError if:

  • The input exceeds MAX_FILE_SIZE
  • The minified output is not valid UTF-8

§Examples

let html = "<html>  <body>  <p>Hello</p>  </body>  </html>";
let minified = minify_html_string(html)?;
assert_eq!(minified, "<html><body><p>Hello</p></body></html>");