Registry / devops / minify-html-wasm

minify-html-wasm

JSON →
library0.1.1jsnpmunverified

WASM wrapper around the Rust crate minify-html, providing extremely fast HTML + JS + CSS minification. Version 0.1.1 is stable. It leverages WebAssembly for near-native performance and offers a comprehensive set of minification options. Unlike JavaScript-based minifiers, this package runs the Rust minify-html library in the browser or Node.js via WASM, delivering high speed and consistency across environments.

npm install minify-html-wasm
INSTALL
IMPORT
SIG · MINIFY-HTML-WASM
M
minify-html-wasm
devopsjavascriptv0.1.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

init
import init, { minify } from 'minify-html-wasm'
const init = require('minify-html-wasm')
ESM-only package; defaults to WebAssembly initialization function.
minify
import { minify } from 'minify-html-wasm'
const minify = require('minify-html-wasm').minify
Named export; must be used after await init().
MinifyOptions
import type { MinifyOptions } from 'minify-html-wasm'
import { MinifyOptions } from 'minify-html-wasm'
TypeScript type, not a runtime value.

Initialize the WASM module and minify an HTML string with options.

import init, { minify } from 'minify-html-wasm'; const encoder = new TextEncoder(); const decoder = new TextDecoder(); await init(); const input = '<p> Hello, world! </p>'; const minified = decoder.decode( minify(encoder.encode(input), { keep_spaces_between_attributes: true, keep_comments: true, }) ); console.log(minified);
Debug
Known issues
gotchainit() must be called before any minify() call; otherwise panic occurs.
fix
Ensure await init() is executed before using minify().
affects: >=0.0.1
breakingInput and output are Uint8Array, not strings; requires TextEncoder/TextDecoder.
fix
Encode strings with TextEncoder and decode with TextDecoder.
affects: >=0.1.0
deprecatedThe web/wasm path for init() URL is changing; future versions may not support CDN loading without bundler.
fix
Use default init() without URL for Node.js; for browser, bundle the WASM file.
affects: >=0.1.0
gotchaOptions object is required; passing undefined or incomplete options may cause unexpected behavior.
fix
Always provide a complete MinifyOptions object (all fields optional but object must exist).
affects: >=0.0.1
gotchaVery large HTML can cause WASM memory errors; no streaming support.
fix
Split large documents into chunks or use a streaming minifier.
affects: >=0.0.1
Errors
Common errors & fixes
Error: WebAssembly.instantiate(): expected magic word
init() called with an incorrect URL or the WASM binary is not loaded properly.
fix
Provide a valid URL to the WASM file or use default init() which expects the WASM to be in the same directory.
TypeError: minify is not a function
imported minify incorrectly (e.g., default import) or init not awaited.
fix
Use named import: import { minify } from 'minify-html-wasm' and ensure init() completes.
Error: Expected a Uint8Array
Passed a string instead of Uint8Array to minify.
fix
Encode strings with TextEncoder before passing: const input = new TextEncoder().encode(htmlString);
Upgrade
Version history
0.1.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
minify-html-wasm — npm install minify-html-wasm · libregistry