Spec-Zone.ru › htmx

htmx.config

Configures htmx behavior globally

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
allowEmptySwapAfterOOB false Allow empty main swap after OOB extraction
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

See Also

  • HCON
  • hx-config

Licensed under the Zero-Clause BSD License.
https://four.htmx.org/reference/config/htmx-config/

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API