Open nerdoc opened 2 years ago
Oh, some additional info: The problem is that when you use "defer" in the script tag, the extension does not work. I removed the "defer" attr (from the main htmx.js file) - and the connection worked immediately. How can that be?
The reason is this fragment of code https://github.com/bigskysoftware/htmx/blob/master/src/htmx.js#L3224-L3230
Basically, here is what happens when you load htmx without defer
DOMContentLoaded
handlerAnd here is what happens when script is deferred
We were bitten by this bug too. As a temporary measure, we're using the hx-ws
attribute instead of the extension.
@Renerick That sounds fairly easy to fix (I haven't worked on JS stuff before, though). Should I give it a shot? My plan would be to simply store a boolean variable (something like htmxWSInitializerExecuted
) and if it's true, run the extension's initialization manually instead of hooking up to htmx events.
Maybe this should be done for other extensions as well, though, like the sse one (see #915)
Update on this:
defer
scripts have already executedDid this get resolved in the interim somehow? Should it be marked closed?
I am struggling with the WS extension on HTMX 1.7.0. Maybe This is not a bug, but I couldn't find any information across the internet, and at least, the the documentation is a bit sparse about extensions usage... When I use the old-style
hs-ws="connect:/chatroom/
, I get a connection to my Django (4,0)/Channels(3,0,5) setup, but if I change that attr to `hs-ext="ws" ws-connect="/chatroom/" - nothing happens, a connection is never established.HTMX and the ws extension is loaded correctly (tried with CDN too):
The Extension usage docs say how to use them - as small hint - you should add a link to each Extension at the beginning of the section to this usage section, it's not as easy to find as you think, from a newcomer's perspective, or at least change the line mentioning the extension docs, to point newcomers to the correct place:
In the docs, click on extensions, there is no hint how to install them, just
Just change that to
That would help find the install section.
But nothing helped bringing the WS extension to life.