Bug report
Using htmx 4.0.0-beta6 with the hx-preload extension.
When preloading a link with a relative hx-get URL, the preload request is made successfully, but the cached response is not reused on click.
Example:
<a
hx-get="https://domain.com/some/url"
hx-preload="mouseover timeout:10s">
Some link
</a>
Steps to reproduce:
Hover the link.
Wait for the preload request to complete.
Click the link.
Expected:
The click should reuse the preloaded response.
Actual:
A second GET request is sent.
Debugging showed:
cached action : https://domain.com/some/url
current action: /some/url
The comparison in hx-preload.js:
elt._htmx.preload.action === ctx.request.action
This fails because the URLs are semantically identical but different strings.
A possible fix (tested locally):
elt._htmx.preload.action === new URL(ctx.request.action, location.href).href
This normalizes the URL before comparison.
Environment:
htmx: 4.0.0-beta6
hx-preload: 4.0.0-beta6
Browser: Chrome/Firefox
Bug report
Using htmx 4.0.0-beta6 with the hx-preload extension.
When preloading a link with a relative
hx-getURL, the preload request is made successfully, but the cached response is not reused on click.Example:
Steps to reproduce:
Hover the link.
Wait for the preload request to complete.
Click the link.
Expected:
The click should reuse the preloaded response.
Actual:
A second GET request is sent.
Debugging showed:
The comparison in hx-preload.js:
This fails because the URLs are semantically identical but different strings.
A possible fix (tested locally):
This normalizes the URL before comparison.
Environment:
htmx: 4.0.0-beta6
hx-preload: 4.0.0-beta6
Browser: Chrome/Firefox