`hx-boost` duplicates htmx-supplied `<style>` in the head in v1.8.6 and above
I'm trying out htmx locally on a simple flat-file site. Everything works well, except I've noticed the htmx-supplied <style> tag seem to get duplicated in the <head> on every hx-boosted link. This problem only occurs for me on versions 1.8.6 and above, including the latest 1.9.5.
Here's what my head element looks like after clicking boosted links about ten times. Notice the duplicated style tags that have built up:
👉 Thank you so much for making htmx available. It's been great to try a different take on web apps!
I have the same issue. Were you able to resolve it?
Can you post a minimal example to replicate the issue?
Are you swapping the body? Any OOB swaps?
So for me this was happening using hx-boost and swapping the full body, no oob swaps. I guess it might had to do with me not moving all scripts in the head, which I have read only later about. It over and over added the aos styles there and the aos script was in the body.
However, I now changed it to use the multi-swap extension instead for a more granular swapping experience and everything works like a charm.
Apologies, as it's a bit time-consuming to disentangle it to see when it does and does not occur. I was able to solve my issue locally by moving my <script src="/dist/index.js"></script> line into the <head> element; it was previously at the bottom of the <body> element.
The original problem seems to appear for me when these two are both true:
- using NPM and a bundler (esbuild in my case) to install/package up htmx
- -and- the
<script>tag is in the<body>rather than the<head>
The problem goes away for me when either:
- using the raw downloadable htmx file from unpkg, regardless of where the
<script>tag is - -or- the
<script>tag is in the<head>, regardless of how htmx was installed
no longer relevant