A Bootstrap 5 landing page demonstrating WebAssembly technology with an interactive HTML minifier powered by Rust and the @minify-html/wasm package.
- 📖 Educational Landing Page: Explains WebAssembly technology and its benefits
- 🔧 Interactive Minifier: Try HTML minification directly in the browser
- ⚡ High Performance: Uses Rust-compiled WASM for ultra-fast minification
- 🎨 Modern UI: Built with Bootstrap 5 for a clean, responsive design
- 📊 Browser Compatibility Table: Shows WASM support across browsers
- Node.js 16+ (for npm package management)
- A local web server (Python's built-in server works great)
-
Clone and install dependencies:
git clone <your-repo> cd wasm-minify npm install
-
Build WASM files:
npm run build
-
Start development server:
npm run dev
-
Open in browser:
http://localhost:8081
npm run build- Extract and setup WASM files from npm packagenpm run dev- Build WASM files and start development servernpm run serve- Start development server (assumes WASM files are already built)npm run install-wasm- Extract WASM files only
wasm-minify/
├── index.html # Main landing page
├── package.json # npm configuration
├── scripts/
│ └── install-wasm.js # WASM extraction script
├── wasm/ # Generated WASM files (gitignored)
│ ├── minify_html_wasm.js
│ ├── index_bg.js
│ └── minify_html_wasm_bg.wasm
└── README.md
This project demonstrates how to integrate WASM modules in browser-based applications without bundlers:
- npm Dependency Management: The
@minify-html/wasmpackage is managed as a regular npm dependency - Build-time Extraction: A Node.js script extracts the WASM files from
node_modules - Custom Wrapper: Generates a browser-compatible wrapper that handles WASM initialization
- Direct Import: The HTML page imports the WASM module using ES6 imports
- ✅ Version Control: WASM dependency versions are locked in
package.json - ✅ Reproducible Builds: Anyone can run
npm install && npm run buildto get the same setup - ✅ No Bundler Required: Works with simple file serving
- ✅ Automatic Updates: Update WASM packages with standard
npm update
The project uses a custom initialization pattern that:
- Fetches the WASM binary using
fetch()to avoid MIME type issues - Properly sets up import bindings that the WASM module expects
- Handles fallbacks for servers without proper WASM MIME type configuration
- Manages memory and exports correctly
Works in all modern browsers supporting:
- ES Modules
- WebAssembly
- Fetch API
- TextEncoder/TextDecoder
Supported browsers: Chrome 61+, Firefox 60+, Safari 11+, Edge 16+
To integrate other WASM packages:
-
Add the package to
package.json:npm install @your-wasm/package
-
Modify
scripts/install-wasm.jsto extract the new package files -
Update the import paths in your HTML/JS files
The minifier accepts various configuration options:
const config = {
keep_spaces_between_attributes: false,
keep_comments: false,
minify_css: true,
minify_js: true,
remove_processing_instructions: false,
// ... more options
};See the minify-html documentation for all available options.
npm run build- Serve
.wasmfiles withapplication/wasmMIME type (recommended but not required) - Support for ES modules (most modern servers do this automatically)
Apache (.htaccess):
AddType application/wasm .wasmNginx:
location ~* \.wasm$ {
add_header Content-Type application/wasm;
}- Fork the repository
- Create a feature branch
- Make your changes
- Test with
npm run dev - Submit a pull request
MIT License - see LICENSE file for details.
