html_generator::performance

Function minify_html

Source
pub fn minify_html(file_path: &Path) -> Result<String>
Expand description

Minifies HTML content from a file with optimized performance.

Reads an HTML file and applies efficient minification techniques to reduce its size while maintaining functionality and standards compliance.

§Arguments

  • file_path - Path to the HTML file to minify

§Returns

Returns the minified HTML content as a string if successful.

§Errors

Returns HtmlError if:

  • File reading fails
  • File size exceeds MAX_FILE_SIZE
  • Content is not valid UTF-8
  • Minification process fails

§Examples

let path = Path::new("index.html");
let minified = minify_html(path)?;
println!("Minified HTML: {} bytes", minified.len());