Problem
When using minify-html, attributes like @htmx:afterOnLoad — which are used in Alpine.js for event binding — are automatically lowercased to @htmx:afteronload. This causes Alpine.js to no longer recognize the event, because event attribute names are case-sensitive in Alpine.js.
Example input (original, works):
<button
hx-get="/api/data"
hx-swap="none"
@htmx:afterOnLoad="doSomething()"
>
Refresh
</button>
Minified output (broken):
<button
hx-get="/api/data"
hx-swap="none"
@htmx:afteronload="doSomething()"
>
Refresh
</button>
This breaks Alpine.js functionality, because @htmx:afteronload is not the same event as @htmx:afterOnLoad.
Why this matters
This issue affects anyone using HTMX + Alpine.js together — a common lightweight frontend combo — especially for binding to HTMX lifecycle events.
Other impacted use cases:
- Web components using camelCase properties or event handlers
- Frameworks expecting specific casing (e.g. Vue custom directives)
- JSX SSR hydration mismatches
- Any case-sensitive
data-* or custom attribute conventions
Suggested fix
Add a new option:
preserve_attribute_case: true
When enabled, this option would prevent minify-html from converting attribute names to lowercase, preserving compatibility with case-sensitive frontend environments.
Environment
minify-html version: (fill in)
- Usage: (CLI / Rust / WASM / Python)
- Frontend: Alpine.js + HTMX
Related keywords
@htmx:afterOnLoad case issue
alpine.js event binding
camelCase attributes
attribute lowercasing breaks behavior
preserve attribute case
Closing note
Even though HTML treats attribute names as case-insensitive, JavaScript frameworks don’t, and preserving attribute casing is essential for modern frontend tooling.
Problem
When using
minify-html, attributes like@htmx:afterOnLoad— which are used in Alpine.js for event binding — are automatically lowercased to@htmx:afteronload. This causes Alpine.js to no longer recognize the event, because event attribute names are case-sensitive in Alpine.js.Example input (original, works):
Minified output (broken):
This breaks Alpine.js functionality, because
@htmx:afteronloadis not the same event as@htmx:afterOnLoad.Why this matters
This issue affects anyone using HTMX + Alpine.js together — a common lightweight frontend combo — especially for binding to HTMX lifecycle events.
Other impacted use cases:
data-*or custom attribute conventionsSuggested fix
Add a new option:
preserve_attribute_case: trueWhen enabled, this option would prevent minify-html from converting attribute names to lowercase, preserving compatibility with case-sensitive frontend environments.
Environment
minify-htmlversion: (fill in)Related keywords
@htmx:afterOnLoadcase issuealpine.jsevent bindingcamelCaseattributesattribute lowercasing breaks behaviorpreserve attribute caseClosing note
Even though HTML treats attribute names as case-insensitive, JavaScript frameworks don’t, and preserving attribute casing is essential for modern frontend tooling.