htmx icon indicating copy to clipboard operation
htmx copied to clipboard

Npm module for extensions

Open believelody opened this issue 1 year ago • 2 comments

Hi there, I installed htmx via npm module. I want to also use some extensions. But mix htmx from npm and extensions in script tag doesn't work. Are there npm module equivalent for extensions ? Or any workaround to use extensions with htmx in .js files ?

Sincerely

believelody avatar Apr 04 '24 22:04 believelody

Can you post the part of your code/config you are referring to?

"But mix htmx from npm and extensions in script tag doesn't work"

The problem is not clearly described. Always include code examples and detailed steps to reproduce when filing Issues

defenestrator avatar Apr 22 '24 22:04 defenestrator

@believelody thank you - this is a very relevant question.

All extensions can be installed using npm. The package naming is htmx-ext-extension-name (replace extension-name with the name of the extension), except for idiomorph. See for example htmx-ext-preload npm package. I have opened a PR which adds npm installation instructions to the extension documentation.

Extensions can currently be imported as ESM modules with this workaround. I have opened another PR to make it possible to integrate them with a clean ESM approach like this:

import `htmx.org`;
import `htmx-ext-extension-name`; // Replace `extension-name` with the extension name

marisst avatar Dec 20 '24 23:12 marisst