Skip to main content

minify_js

Function minify_js 

Source
pub fn minify_js(js: &str) -> String
Expand description

Minifies JavaScript by removing comments and collapsing whitespace.

ssg’s own implementation rather than a dependency. It is deliberately conservative: it does not rename, reorder or rewrite anything, so it cannot change what a script does. String, template and regex literals are copied verbatim, and the division operator is left alone.

§Examples

use ssg::plugins::minify_js;

let out = minify_js("const m = { rootMargin: \"0px 0px -15% 0px\" };");
assert_eq!(out, "const m={rootMargin:\"0px 0px -15% 0px\"};");