htmx.config.morphIgnore
Preserves attribute prefixes during morphing
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 morph -
morphSkipChildren— CSS selector for elements whose children are preserved
Licensed under the Zero-Clause BSD License.
https://four.htmx.org/reference/config/htmx-config-morphIgnore/