htmx:before:init
Fires before element initialization
The htmx:before:init event fires before a specific element is initialized with htmx metadata.
When It Fires
During element processing, before htmx attaches its internal metadata structure to the element.
Event Detail
Empty - no additional context provided.
Example
htmx.on('htmx:before:init', (evt) => {
console.log('Initializing element:', evt.target);
}); Cancel this event to prevent htmx from initializing the element.
This runs early in the initialization lifecycle, before attributes are fully parsed.
Licensed under the Zero-Clause BSD License.
https://four.htmx.org/reference/events/htmx-before-init/