Integration · C++17
A whole-buffer API with explicit optimisation policy.
The public API accepts whole buffers and returns either a complete transformed buffer or a controlled error. File discovery, naming and write policy stay with the caller.
Include and link
#include <minify/Minify.h>
std::string output;
std::string error;
if (!minify::javascript(source, output, error)) {
// Preserve the original and report error.
} Minify++ is written in C++17. The public header does not expose Nift types or a third-party runtime.
Format-specific entry points
bool minify::html(input, output, error);
bool minify::css(input, output, error);
bool minify::javascript(input, output, error);
bool minify::jsx(input, output, error);
bool minify::json(input, output, error);
bool minify::xml(input, output, error);
bool minify::svg(input, output, error); JavaScript and JSX also have overloads that accept minify::Options.
Choose the JavaScript policy explicitly
minify::Options options;
options.optimization = minify::OptimizationLevel::Structured;
options.mangle_top_level = false;
if (!minify::javascript(source, output, error, options)) {
// No partial output is usable on failure.
} OptimizationLevel contains Conservative, Structured and Aggressive. Options also expose structured JSX-expression handling, an explicit top-level closed-world mangling switch, a property-mangling allowlist, and per-pass disabling for diagnostic or integration control. Conservative behavior remains the default.
Dispatch by format
minify::Format format;
if (!minify::format_for_extension(".css", format)) {
// Unsupported extension.
}
if (!minify::run(format, input, output, error)) {
// Format-specific failure.
} Format contains Html, Css, JavaScript, Jsx, Json, Xml and Svg. minify::format_version is currently 1; it identifies the supported format/API contract rather than the CLI release number.
Diagnostic JavaScript surfaces
The API also exposes deterministic binding, mangling, effect, IR and CFG signatures used by tests, benchmarks and optimizer diagnostics. They are evidence/debugging surfaces, not a promise that Minify++ is a general-purpose JavaScript compiler frontend.
Ownership and concurrency
The library is stateless and whole-buffer. Inputs are immutable strings supplied by the caller; output and error strings are caller-owned. No global project state, current directory, build graph or framework configuration is consulted.
What the library deliberately does not do
- open, replace or rename files;
- walk directories or infer a build graph;
- compile TypeScript, JSX or Sass;
- bundle or tree-shake modules;
- infer that public properties are safe to rename;
- choose whether a failed optimisation should block deployment.
Those boundaries make embedding predictable. A host can choose its own transaction, logging and failure policy while reusing exactly the same transformation engine tested by the standalone CLI.
Nift integration
Nift build engine
↓ configured output extension only
public Minify++ API
↓
final artifactNift’s copy is protected by a synchronization gate covering the implementation, public API and associated contract assets. Minify++ remains independently buildable and testable.
Integration checklist
- Select the format explicitly or validate the extension.
- Keep the original until minification succeeds.
- Treat an error as a failed optimisation, never as partial output.
- Use conservative mode unless the stronger JavaScript contract is intentional.
- Treat top-level/property mangling as a caller-owned closed-world decision.
- Retain format-specific regressions for any production defect.