The htmx.config.morphIgnore option is an array of attribute name prefixes to preserve when morphing DOM elements. An attribute is ignored if its name starts with any entry in the array.
Default: ["data-htmx-powered"]
Example
htmx.config.morphIgnore = ["data-htmx-powered", "data-analytics"];
<meta name="htmx-config" content='{"morphIgnore":["data-htmx-powered","data-analytics"]}'>
With "data-" in the list, all data-* attributes are preserved during morph — the server response cannot overwrite them. Exact attribute names also work since a string starts with itself (e.g. "style" matches 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