[RFC] Trigger preload module on htmx:load

I was having some trouble getting preloading working on a fresh page load until making this tweak. But it worked fine after doing a single boosted navigation. This led me to believe there was an issue with how preloading was initialized on links. This may not be the right fix, but it seems to be working for me.

For context, the JS bundle (which contains HTMX) on my site (in an `<script async="true" ...` tag) usually arrives after the DOM is finished loading  , which probably has something to do with why this wasn't working. HTMX otherwise works fine.
This commit is contained in:
Leif Foged
2022-08-14 22:14:09 -07:00
committed by GitHub
parent 3e2e0ba936
commit 39c2542013

2
dist/ext/preload.js vendored
View File

@@ -7,7 +7,7 @@ htmx.defineExtension("preload", {
onEvent: function(name, event) {
// Only take actions on "htmx:afterProcessNode"
if (name !== "htmx:afterProcessNode") {
if (name !== "htmx:afterProcessNode" && name !== "htmx:load") {
return;
}