The htmx.config.morphIgnore option lists attribute prefixes to preserve during morphing.
An attribute is preserved when its name starts with a listed prefix.
Default: ["data-htmx-powered"]
Example
htmx.config.morphIgnore = ["data-htmx-powered", "data-analytics"];
<meta name="htmx-config" content='{"morphIgnore":["data-htmx-powered","data-analytics"]}'>
Add "data-" to preserve every data-* attribute.
Exact names also work. For example, "style" preserves only the style attribute.
Use Cases
- Preserve client-side state stored in
data-*attributes (e.g. from thehx-livedataproxy) - Prevent CSP violations from inline
styleattribute copying (add"style") - Protect framework-managed attributes from being overwritten during morph
See Also
morphSkip— CSS selector for elements to completely skip during morphmorphSkipChildren— CSS selector for elements whose children are preserved