head extension fires duplicate event
Author: scrhartleyCreated Sep 19, 2026Updated Sep 20, 2026
Note: This issue still exists after PR #4083.
Example below of head extension firing duplicate event.
The use of hx-preserve is just to make the script tags take a different path through the code, in order to better isolate this bug.
Output in console:
htmx:head:before:remove META
htmx:head:before:remove METAPage 1:
<!DOCTYPE html>
<html>
<head>
<script "hx-preserve" src="https://cdn.jsdelivr.net/npm/[email protected]/dist/htmx.js"></script>
<script "hx-preserve" src="hx-head.js"></script>
<meta name="description" content="An htmx page" />
</head>
<body hx-on="htmx:head:before:remove -> console.log(event.type, headElement.tagName)">
<a href="page2.html" hx-boost="true">Go to page 2</a>
</body>
</html>Page 2:
<!DOCTYPE html>
<html>
<head>
<script "hx-preserve" src="https://cdn.jsdelivr.net/npm/[email protected]/dist/htmx.js"></script>
<script "hx-preserve" src="hx-head.js"></script>
</head>
<body>This is page 2</body>
</html>Source: bigskysoftware/htmx