Debian Codegraph @

www/src/content/reference/03-events/07-htmx-before-cleanup.md

raw symbols SCIP
1 ---
2 title: "htmx:before:cleanup"
3 description: "Before htmx removes element data"
4 ---
5
6 The `htmx:before:cleanup` event fires before htmx removes listeners and internal data from an element.
7
8 ## When It Fires
9
10 - Before an element is removed from the DOM during a swap
11 - Before htmx re-processes an element
12
13 ## Event Detail
14
15 Empty - no additional context provided.
16
17 ## Example
18
19 ```javascript
20 htmx.on('htmx:before:cleanup', (evt) => {
21 console.log('Cleaning up:', evt.target);
22 // Save state or clean up custom data
23 });
24 ```
25
26 Use this to perform cleanup operations before htmx removes its data.