| 1 | --- |
| 2 | title: "htmx:before:init" |
| 3 | description: "Before a specific element is initialized" |
| 4 | --- |
| 5 | |
| 6 | The `htmx:before:init` event fires before a specific element is initialized with htmx metadata. |
| 7 | |
| 8 | ## When It Fires |
| 9 | |
| 10 | During element processing, before htmx attaches its internal metadata structure to the element. |
| 11 | |
| 12 | ## Event Detail |
| 13 | |
| 14 | Empty - no additional context provided. |
| 15 | |
| 16 | ## Example |
| 17 | |
| 18 | ```javascript |
| 19 | htmx.on('htmx:before:init', (evt) => { |
| 20 | console.log('Initializing element:', evt.target); |
| 21 | }); |
| 22 | ``` |
| 23 | |
| 24 | This runs early in the initialization lifecycle, before attributes are fully parsed. |