htmx 4.0 is under construction — migration guide

htmx:before:init

Before a specific element is initialized

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); });

This runs early in the initialization lifecycle, before attributes are fully parsed.