Skip to main content

minify_js

Function minify_js 

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

ssg’s own CSS and JavaScript minifiers, re-exported so the whole minification surface lives behind one module.

These replace lightningcss and oxc_minifier, which sat behind an optional minify feature. A minifier rewrites every byte the generator emits; keeping it in-tree means it is covered by this crate’s own tests and cannot change underneath a release. 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\"};");