8000 Alpine.js + HTMX integration breaks due to lowercased event attributes (@htmx:afterOnLoad → @htmx:afteronload) · Issue #246 · wilsonzlin/minify-html · GitHub
[go: up one dir, main page]

Skip to content

Alpine.js + HTMX integration breaks due to lowercased event attributes (@htmx:afterOnLoad → @htmx:afteronload) #246

Open

Description

@CDU-Ge

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 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.

Activity

  1. XChikuX commented on Oct 24, 2025

    @XChikuX

    I have the same issue.

  2. avsaase commented on Dec 29, 2025

    @avsaase

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0