Attributes33Requests hx-getIssues a GET request to the specified URL hx-postIssues a POST request to the specified URL hx-putIssues a PUT request to the specified URL hx-patchIssues a PATCH request to the specified URL hx-deleteIssues a DELETE request to the specified URL Request Control hx-triggerControls when the element issues a request hx-swapControls how the response is inserted hx-targetControls where the response is inserted hx-selectControls which part of the response to insert hx-swap-oobMarks response elements to swap into the page by ID hx-select-oobPicks response elements to swap into the page by ID hx-confirmShows a confirmation dialog before the request Scripting hx-onRuns inline JavaScript when an event fires Data hx-valsAdds values to request parameters hx-includeIncludes additional element values in the request hx-headersAdds custom headers to the request hx-encodingSets the request encoding type History hx-push-urlPushes the URL into browser history hx-replace-urlReplaces the current URL in browser history hx-history-eltMarks the element to swap on history restore Enhancements hx-boostConverts links and forms to AJAX hx-preloadPreloads content before the user triggers a request hx-optimisticShows optimistic content during the request Advanced hx-indicatorSpecifies the loading indicator element hx-statusHandles responses differently by status code hx-syncSynchronizes requests between elements hx-validateValidates before submitting the request hx-disableDisables elements during the request hx-ignoreDisables htmx processing for the element hx-preservePreserves the element during swaps hx-actionSpecifies the URL to receive the request hx-methodSpecifies the HTTP method for the request hx-configConfigures request behavior with JSON Headers18Request HX-RequestIndicates a request was made by htmx HX-Request-TypeIndicates if this is a partial or full page request HX-Current-URLContains the URL of the browser when the request was made HX-SourceIdentifies the element that triggered the request HX-TargetThe element that will receive the response HX-BoostedIndicates a boosted navigation request HX-History-Restore-RequestIndicates history navigation (back/forward) AcceptContent types htmx accepts from the server Last-Event-IDLast received SSE event ID for reconnection Response HX-TriggerTrigger client-side events from the server HX-LocationClient-side AJAX navigation to a new URL HX-RedirectClient-side redirect to a new URL HX-RefreshTrigger a full page reload HX-RetargetOverride the swap target from the server HX-ReswapOverride the swap style from the server HX-ReselectOverride the content selection from the server HX-Replace-UrlReplace the current URL in the browser history HX-Push-UrlPush a URL into the browser history stack Events31 htmx:config:requestConfigure request before it's sent htmx:before:requestImmediately before fetch is called htmx:after:requestAfter response is received htmx:finally:requestAt the end of request lifecycle htmx:before:swapBefore content is swapped into DOM htmx:after:swapAfter content is swapped into DOM htmx:before:cleanupBefore htmx removes element data htmx:after:cleanupAfter listeners and data are removed htmx:confirmShow confirmation dialog before request htmx:errorWhen an error occurs during request htmx:abortTrigger to abort an ongoing request htmx:before:initBefore a specific element is initialized htmx:after:initAfter an element is fully initialized htmx:before:processBefore htmx processes a DOM node htmx:after:processAfter htmx processes a DOM node htmx:process:{type}Custom template processing htmx:after:implicitInheritanceAfter implicit inheritance is applied htmx:before:history:updateBefore browser history is updated htmx:after:history:updateAfter browser history is updated htmx:after:history:pushAfter a push state action htmx:after:history:replaceAfter a replace state action htmx:before:history:restoreBefore restoring from history htmx:before:viewTransitionBefore View Transition API starts htmx:after:viewTransitionAfter View Transition completes loadFired immediately after initialization intersectElement enters viewport everyPeriodic polling trigger htmx:before:responseAfter a response is received but before the body is consumed htmx:before:settleBefore the settle phase begins after a swap htmx:after:settleAfter the settle phase completes htmx:response:errorWhen an HTTP error status (4xx/5xx) is received Config23 htmx.configConfigure htmx behavior globally htmx.config.defaultSwapDefault swap style for responses htmx.config.defaultTimeoutDefault timeout for requests in milliseconds htmx.config.extensionsComma-separated list of extensions to load htmx.config.historyControl htmx browser history management htmx.config.implicitInheritanceEnable implicit attribute inheritance htmx.config.includeIndicatorCSSInclude default indicator CSS htmx.config.indicatorClassCSS class for loading indicators htmx.config.logAllLog all htmx events to console htmx.config.modeSet request mode for fetch API htmx.config.morphIgnoreAttributes to ignore during morphing htmx.config.morphSkipSkip morphing for specific elements htmx.config.morphSkipChildrenSkip morphing children of specific elements htmx.config.noSwapHTTP status codes that skip swap htmx.config.prefixSet a secondary attribute prefix htmx.config.requestClassCSS class applied during requests htmx.config.transitionsEnable View Transitions API support htmx.versionCurrent htmx version (read-only) htmx.config.defaultFocusScrollScroll to the focused element after a swap htmx.config.defaultSettleDelayDelay between the swap and settle phases in milliseconds htmx.config.inlineScriptNonceNonce value added to inline scripts generated by htmx htmx.config.morphScanLimitMaximum number of siblings scanned when matching elements during morphing htmx.config.metaCharacterCustom character used instead of `:` for attribute modifiers Methods11 htmx.ajax()Issues an htmx-style ajax request htmx.find()Find first matching element htmx.findAll()Find all matching elements htmx.on()Listen for htmx events htmx.onLoad()Execute callback when elements are loaded htmx.parseInterval()Parse time intervals to milliseconds htmx.process()Process htmx attributes on element htmx.registerExtension()Register htmx extension htmx.timeout()Create a timeout promise htmx.trigger()Trigger custom events htmx.swap()Perform an HTML content swap into the DOM