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 META
Page 1:
<!DOCTYPE html>
<html>
<head>
<script "hx-preserve" src="https://cdn.jsdelivr.net/npm/htmx.org@4.0.0/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/htmx.org@4.0.0/dist/htmx.js"></script>
<script "hx-preserve" src="hx-head.js"></script>
</head>
<body>This is page 2</body>
</html>
Note: This issue still exists after PR #4083.
Example below of head extension firing duplicate event.
The use of
hx-preserveis just to make the script tags take a different path through the code, in order to better isolate this bug.Output in console:
Page 1:
Page 2: