You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Alpine.js + HTMX integration breaks due to lowercased event attributes (@htmx:afterOnLoad → @htmx:afteronload) #246
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.
This breaks A
8536
lpine.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.
What the use of lowercasing the attributes (or anything really) in the first place? It doesn't make the HTML smaller and it's an operation that takes time.
Activity
XChikuX commentedon Oct 24, 2025
I have the same issue.
Add preserve_attribute_case option to address issue #246
avsaase commentedon Dec 29, 2025
What the use of lowercasing the attributes (or anything really) in the first place? It doesn't make the HTML smaller and it's an operation that takes time.