Skip to content

optimize and minimize hx-on code#3783

Merged
1cg merged 2 commits intobigskysoftware:four-devfrom
MichaelWest22:optimize-hx-on
May 6, 2026
Merged

optimize and minimize hx-on code#3783
1cg merged 2 commits intobigskysoftware:four-devfrom
MichaelWest22:optimize-hx-on

Conversation

@MichaelWest22
Copy link
Copy Markdown
Collaborator

@MichaelWest22 MichaelWest22 commented May 5, 2026

Description

The new hx-on modifier code has been added but it could do with some code optimization to minimize the final bundle size.

metadata character code can be simplified
using map to create a mod object with true properties per mods string allows us to remove the has helper and use it as a object access much simpler. Also this means we can safely just pass this mod object to the event listener to set all capture, passive, once and it will ignore the rest.
Also removed the removeEventListener since it is not needed once we pass once option.

Finally put back

                ctx.vals = obj; // make available for json extensions

Which was recently removed accidently which is still used by json extensions to access the raw hx-vals object data with json types preserved.

Corresponding issue:

Testing

No real functional changes and tests still all pass

Checklist

  • I have read the contribution guidelines
  • I have targeted this PR against the correct branch (master for website changes, dev for
    source changes)
  • This is either a bugfix, a documentation update, or a new feature that has been explicitly
    approved via an issue
  • I ran the test suite locally (npm run test) and verified that it succeeded

@MichaelWest22 MichaelWest22 added the htmx 4 Issues specific to htmx version 4 label May 5, 2026
@1cg 1cg merged commit 9b3a279 into bigskysoftware:four-dev May 6, 2026
@1cg
Copy link
Copy Markdown
Contributor

1cg commented May 6, 2026

Thanks Michael!

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

Labels

htmx 4 Issues specific to htmx version 4

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants