Skip to content

Fixing #3165 - #3166

Closed
mrinc wants to merge 1 commit into
bigskysoftware:devfrom
mrinc:bugfix/3165
Closed

Fixing #3165#3166
mrinc wants to merge 1 commit into
bigskysoftware:devfrom
mrinc:bugfix/3165

Conversation

@mrinc

@mrinc mrinc commented Feb 2, 2025

Copy link
Copy Markdown

Description

Fixes case where htmx is loaded async and DOMContentLoaded is never fired.
By using window.onload as well, we cover the case where it is not fired.
No change to current behavior but fixes the case of dynamically loading htmx.

Corresponding issue: #3165

Testing

Lets discuss how we should test this one and then can just update the test suite accordingly.
It's specific case where the htmx lib is loaded async.
htmx itself operates the same, the big issue occurs when you try go back in the browser (I could be missing something...).
However this does bring up other notes where the ready function isn't run - so we should be testing for that currently.
So it's not just, lets add a single test case, it's we should add a single test case for the ready function in the 2 cases, but we should also be running all the tests again, in an async loaded state to make sure htmx behaves the same in both load-state cases.

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

Fixes case where htmx is loaded async and DOMContentLoaded is never fired.
@alexpetros

Copy link
Copy Markdown
Collaborator

Sorry, we've been through the ringer on this one and simply don't support loading htmx as a module this way. We make a good-faith effort but if what we have right now doesn't work you will need to do your own workaround.

I think we'd still be okay with exposing an initialize method if you want to load htmx async and then initialize it yourself.

@alexpetros alexpetros closed this Jul 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants