⚠️ EXPERIMENTAL – See Scope & limitations
Looking for a tiny web development ecosystem? See: Minimum Viable Web
- Tree-shaking (
TreeShaker) - JS Minification (
Minifier) - CSS Minification (
CSSMinifier) - HTML Minification (
HTMLMinifier) - Bundling (
Bundler) - Module system (
ModuleSystem) - Obfuscation (
Obfuscator) - Tokenizing parser (
tokenize/findModuleSyntax)
Install from GitHub Packages:
npm install @minimum-viable-web/minibunNote: You'll need to authenticate with GitHub Packages. Create a .npmrc file in your project root:
@minimum-viable-web:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=YOUR_GITHUB_TOKEN
Or set the GITHUB_TOKEN environment variable. You can create a Personal Access Token with read:packages permission at GitHub Settings > Developer settings > Personal access tokens.
import {
TreeShaker,
Minifier,
CSSMinifier,
HTMLMinifier,
Bundler,
ModuleSystem,
Obfuscator,
Pipeline,
} from '@minimum-viable-web/minibun';import { CSSMinifier } from '@minimum-viable-web/minibun';
const minifier = new CSSMinifier();
const output = minifier.minifyCSS(`
/* Main styles */
.card {
color: red;
padding: 10px;
}
`);
// Output: ".card{color:red;padding:10px}"The CSSMinifier removes comments, collapses whitespace, strips unnecessary spaces around {}:;,, and removes trailing semicolons — while preserving quoted string literals (e.g. content: "...", url("...")).
Options:
keepComments: true— preserve original formatting (no minification)
Pipeline integration:
const pipeline = new Pipeline({ outputFile: '' })
.withModules(modules)
.useCSSMinifier();
// Or via JSON config:
Pipeline.fromJSON({ pipeline: { minifyCSS: true } });import { HTMLMinifier } from '@minimum-viable-web/minibun';
const minifier = new HTMLMinifier();
const output = minifier.minifyHTML(`
<!-- page header -->
<div class="card">
<p> hello </p>
<input disabled="disabled" />
</div>
`);
// Output: '<div class=card><p> hello </p><input disabled></div>'The HTMLMinifier removes comments, collapses whitespace, strips spaces between tags, collapses boolean attributes (disabled="disabled" → disabled), removes unnecessary attribute quotes, and removes trailing slashes on void elements — while preserving content inside <pre>, <code>, <textarea>, <script>, and <style> blocks.
Options:
keepComments: true— preserve original formatting (no minification)collapseBooleanAttributes: true(default) — shorten boolean attributescollapseAttributeQuotes: true(default) — remove quotes from safe attribute values
Pipeline integration:
const pipeline = new Pipeline({ outputFile: '' })
.withModules(modules)
.useHTMLMinifier();
// Or via JSON config:
Pipeline.fromJSON({ pipeline: { minifyHTML: true } });Build the main bundle:
npm run buildBuild all variants (minified, obfuscated, minified+obfuscated):
npm run build:testRun tests:
npm testThis package is published to GitHub Packages. To publish a new version:
-
Manual Publishing:
npm login --registry=https://npm.pkg.github.com --scope=@minimum-viable-web npm publish
-
Automated Publishing:
- Create a GitHub Release, or
- Use the "Publish to GitHub Packages" workflow from the Actions tab
- The workflow will automatically build, test, and publish the package
src/- Primary source code (modular, maintainable)- Edit files here when making changes
- Tests import directly from
src/modules
dist/- Generated build artifacts (do not edit directly)minibun.js- Main single-file bundleminibun-min.js- Minified variantminibun-obf.js- Obfuscated variant (hex-encoded strings)minibun-min-obf.js- Minified + obfuscated variant- Regenerate with
npm run buildornpm run build:test
- Algorithms are implemented with a lightweight tokenizer.
- The tokenizer handles strings, templates, comments, regex literals, and all ES6+ syntax, but there is no full AST — tokens are emitted in sequence without expression parsing.
- CSS and HTML minification use regex-based approaches (no tokenizer needed) that handle standard CSS/HTML including
@-rules, nested blocks, quoted strings, and whitespace-sensitive elements (<pre>,<code>,<textarea>). - Suitable for controlled ES6+ codebases with static module structure:
- Only static
import/exportwith literal specifiers (noimport()dynamic imports). - No analysis of runtime-evaluated code (
eval,new Function(),with). - Tree-shaking uses conservative heuristics; modules with detected side effects are preserved.
- Only static
- For production builds of arbitrary JavaScript, use established tools (esbuild, Rollup, Terser) instead.