Registry / devops / minify-html-attributes

minify-html-attributes

JSON →
library1.0.2jsnpmunverified

Minifies HTML attribute class names, IDs, and data-* attributes coordinated across HTML, CSS, and JS files. v1.0.2 (stable). Useful for additional minification or obfuscation beyond standard minifiers. Processes files via AST parsers and updates references in HTML, CSS, and JavaScript. Built by the Roosevelt framework team but usable standalone. Requires Node >=18.

npm install minify-html-attributes
INSTALL
IMPORT
SIG · MINIFY-HTML-ATTRIB
M
minify-html-attributes
devopsjavascriptv1.0.2
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.

minifyHtmlAttributes
import { minifyHtmlAttributes } from 'minify-html-attributes'
const minifyHtmlAttributes = require('minify-html-attributes')
ESM-only since v1.0.0; no CommonJS support.
minifyHtmlAttributes (default)
import minifyHtmlAttributes from 'minify-html-attributes'
const minifyHtmlAttributes = require('minify-html-attributes').default
Both named and default export exist and are identical.
type Options
import type { Options } from 'minify-html-attributes'
import { Options } from 'minify-html-attributes'
Options is a TypeScript type, not a runtime value; use `import type` for type-only imports.

Demonstrates coordinated minification of class and ID attributes across HTML, CSS, and JS strings.

import { minifyHtmlAttributes } from 'minify-html-attributes'; const result = await minifyHtmlAttributes({ html: '<div class="foo"><p id="bar">Hello</p></div>', css: '.foo { color: red; }', js: 'document.getElementById("bar");', }); console.log(result); // { // html: '<div class="a"><p id="b">Hello</p></div>', // css: '.a { color: red; }', // js: 'document.getElementById("b");' // }
Debug
Known issues
gotchaMay not correctly handle dynamically constructed attribute references in JavaScript (e.g., concatenated strings).
fix
Simplify DOM manipulation code; avoid dynamic references when possible.
affects: >=1.0.0
gotchaRequires well-formed HTML and CSS for AST parsing; templating languages may break.
fix
Ensure input is valid HTML/CSS; preprocess templates if needed.
affects: >=1.0.0
deprecatedNode.js <18 is not supported; the package uses ESM only.
fix
Upgrade Node.js to version 18 or later.
affects: >=1.0.0
gotchaDoes not minify other parts of the code (e.g., JS variable names); must be used with a standard minifier for full minification.
fix
Run standard minifier after this package.
affects: >=1.0.0
Errors
Common errors & fixes
SyntaxError: Unexpected token 'export'
Using CommonJS require() on an ESM-only package.
fix
Use ES module import syntax (import { minifyHtmlAttributes } from 'minify-html-attributes') or enable ESM in your project.
TypeError: Cannot read properties of undefined (reading 'html')
Passing incomplete or malformed options object to minifyHtmlAttributes.
fix
Ensure options contains at least an html, css, or js property with valid strings.
Error: Parsing error in CSS file: ...
Input CSS contains syntax that the CSS parser cannot handle.
fix
Validate CSS syntax; remove unsupported constructs or preprocess with a CSS linter.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

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