#minified #gzipped #html #template #gzip #content-encoding #css #relative-path #line-comment #text-area

macro include-minifier

Include html strings that are automatically minified (optionally gzipped)

2 unstable releases

Uses new Rust 2024

0.2.0 Oct 16, 2026
0.1.0 Apr 23, 2026

#2232 in Procedural macros

Download history 5/week @ 2026-07-31 1/week @ 2026-08-07 3/week @ 2026-08-14 1/week @ 2026-08-21 3/week @ 2026-09-11 1/week @ 2026-09-18 45/week @ 2026-10-16 3/week @ 2026-10-23 42/week @ 2026-10-30 45/week @ 2026-11-06 20/week @ 2026-11-13

110 downloads per month
Used in esp-hal-wifimanager

MIT license

13KB
259 lines

include-minifier

Like include_str!, but html files are minified at compile time, optionally gzipped.

// &'static str
const PANEL: &str = include_minifier::include_minified!("src/panel.html");

// &'static [u8], serve with `Content-Encoding: gzip`
const PANEL_GZ: &[u8] = include_minifier::include_minified_gzip!("src/panel.html");

Paths are relative to the crate's Cargo.toml, and the file is tracked for rebuilds. Non-html files are included unchanged (include_minified_gzip! still gzips them).

The minifier is small and conservative, so it builds fast and never changes behaviour: it removes indentation, blank lines and comments, but leaves <pre>/<textarea>, js strings and template literals untouched and doesn't rewrite js or css. With gzip on top that's within a few hundred bytes of a full minifier.

Dependencies

~2MB
~41K SLoC