The htmx.config object holds the current htmx configuration. You can modify it in JavaScript or set values using a <meta> tag.
Configure via Meta Tag
Set config values with HCON:
<meta name="htmx-config" content="defaultSwap:outerHTML defaultTimeout:5000">
Or JSON:
<meta name="htmx-config" content='{"defaultSwap":"outerHTML","defaultTimeout":5000}'>
Configure via JavaScript
Modify config values directly:
htmx.config.defaultSwap = 'outerHTML'; htmx.config.defaultTimeout = 5000;
Available Options
| Option | Default | Description |
|---|---|---|
logAll | false | Log all htmx events |
prefix | "data-hx-" | Secondary attribute prefix recognized alongside hx- |
metaCharacter | undefined | Character used instead of : in attribute names |
transitions | false | Enable view transitions |
history | true | Enable history support |
mode | "same-origin" | Request mode for fetch() |
defaultSwap | "innerHTML" | Default swap style |
defaultSwapEmpty | undefined | Swap empty main content unless an <hx-partial> was extracted |
defaultFocusScroll | false | Scroll to a focused element after swapping |
defaultSettleDelay | 1 | Delay before settling in milliseconds |
indicatorClass | "htmx-indicator" | CSS class for indicators |
requestClass | "htmx-request" | CSS class during requests |
includeIndicatorCSS | true | Include default indicator CSS |
defaultTimeout | 60000 | Request timeout in milliseconds |
extensions | "" | Extensions to load |
morphIgnore | ["data-htmx-powered"] | Attributes to ignore during morphing |
morphSkip | "[hx-morph-skip]" | Elements to skip while morphing |
morphSkipChildren | "[hx-morph-skip-children]" | Elements whose children are not morphed |
morphScanLimit | 10 | Siblings scanned while matching elements |
noSwap | [204, 304] | HTTP status codes that skip swaps |
implicitInheritance | false | Enable implicit attribute inheritance |
inlineScriptNonce | undefined | Nonce added to inline scripts |