htmx 2 is now available, and both Sprig 2.9.0 and 3.1.0 now include it by default. Not a lot has changed and everything should continue to just work in your Sprig projects, so let’s explore what has changed, and why.
htmx 2.0.0 was released in June 2024 with a few notable changes for Sprig users.
1. So long, IE #
Believe it or not, htmx 1 maintained support for Internet Explorer. That has finally changed in htmx 2, so if, for whatever reason, you need to continue supporting IE, you should manually include htmx 1. This allows for modernisation of the htmx codebase and removing legacy code, making the library easier to maintain.
2. New defaults #
htmx 2 tightens up some default configuration values for security purposes and for matching default browser behaviour.
htmx.config.selfRequestsOnly
was changed fromfalse
totrue
, meaning that AJAX requests are now only allowed to the same domain.htmx.config.scrollBehavior
was changed fromsmooth
toinstant
, causing scrolling to happen instantly in a single jump for boosted links.
3. Module-type specific files #
If you are including htmx as a module, module-type specific files for all three of the major JavaScript module types are now available in the dist
directory.
- ESM Modules:
/dist/htmx.esm.js
- AMD Modules:
/dist/htmx.amd.js
- CJS Modules:
/dist/htmx.cjs.js
4. Upgrading extensions #
All extensions have been moved out of the core repository and into their own repo and website. Most 1.x extensions will work with 2.x, however they should ideally be upgraded.
And that’s all there is to it! No action will be required for the vast majority of Sprig users, but hopefully you feel more in the know of what has changed in htmx 2 and how it might affect you. Read the full announcement here.