bigskysoftware / htmx

</> htmx - high power tools for HTML
https://htmx.org
Other
37.14k stars 1.25k forks source link

External scripts are ignored when using hx-boost #559

Closed xvello closed 2 years ago

xvello commented 3 years ago

Hello,

I am using <body hx-boost="true"> for progressive enhancement of a server-side-rendered website. While it works great, I ran into an issue for a page that has progressive enhancement on a form. I defined JS functions in an inline script in the page, and use them as onclick callbacks works great.

To reduce the size of the pages, I moved these functions to a js file, linked via a <script src="my.js"></script>. While this works if you directly load the page, it fails to load if you start at the index page and navigate to it via boosted links. When it fails, reloading the page (bypassing the boost) makes it work. Moving the script element to the head didn't help either.

I would expect the external JS to be detected and imported when the page is swapped, using the browser's cache to avoid repeated downloads.

xvello commented 3 years ago

After checking the open issues a second time, it looks like this might be a duplicate of https://github.com/bigskysoftware/htmx/issues/379. Hopefully the reproduction case will be helpful to get to the bottom of it?

1cg commented 3 years ago

Yes, this is a dup of #379 will comment over there.

1cg commented 2 years ago

Fix ready for next release:

https://github.com/bigskysoftware/htmx/commit/60a67179941b98132ac577abf1b42ea030231b65

xvello commented 2 years ago

Thank you so much @1cg, your work is very appreciated :bow: