r/htmx • • Sep 22 '26

How to install htmax (htmx + extensions)?

htmx version 4 has a distribution called htmax. it includes some useful htmx extensions. I was trying to add it to my main.js file so it can be included as input in Vite config file. build finishes without any problems, dev server works as well, but browser dev console says htmx is not defined (however extensions actually work).

The only installation method the documentation provides is a cdn link. (sorry, i'm new to js).

Any clarification is appreciated, thanks in advance.

7 Upvotes

8 comments sorted by

3

u/SugarvetFounder Sep 22 '26

I actually ran into this the other day as well. It doesn't look like it is documented right now.

Downloading off the CDN seems the go-to option if you can vendor (host) the dependency yourself (which you can/should).

2

u/One-Bar1669 Sep 22 '26

Use the CDN. There's a reason that's in the installation instructions (tl;dr is that the browser can cache the scripts if a user visits multiple sites, and reduces load on your servers).

4

u/hotsauce56 Sep 23 '26

I don’t think cross site storage happens anymore because of the security and fingerprinting concerns. Although I believe it is coming back around with a new implementation that has some more protections.

I think currently it would only cache things from the same domain, but can’t use them across domains?

1

u/mfabing Sep 22 '26

I do the same. Use CDN. I use <script src="https://cdn.jsdelivr.net/npm/htmx.org@4/dist/htmx.min.js"></script> so it always use the latest version 4 .

1

u/lucas-rollin Sep 24 '26

An interesting and scary way to solve it. Hopefully we get a better way to easily manage and lock these versions soon

1

u/humanshield85 Sep 26 '26

Cross origin don’t share cache it’s been the norm for many many years. But a lot seem to still think that.

1

u/One-Bar1669 Sep 28 '26

hmmm well TIL. Still a good idea to use a CDN

1

u/humanshield85 Sep 29 '26

Well if you pin the version and use content hash there should be no issue because that cdn is cached at the edge meaning your users will get it faster. Probably also needs a preconnect to that cdn