Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding htmx extensions ? #4

Open
RayyanNafees opened this issue Feb 25, 2024 · 7 comments
Open

Adding htmx extensions ? #4

RayyanNafees opened this issue Feb 25, 2024 · 7 comments

Comments

@RayyanNafees
Copy link

How to add htmx extensions using this like json-enc

@xstevenyung
Copy link
Owner

xstevenyung commented Feb 26, 2024

i think htmx's plugins are not supported

so your best bet at the moment is to add the script tag manually to your pages / layouts.

i will have to check if it's possible to include extensions in the plugin

@xstevenyung
Copy link
Owner

found this issue on the htmx repo. i will wait until something happen there but it seems to be a common issue with Vite / any bundler and using HTMX

bigskysoftware/htmx#1690

@RayyanNafees
Copy link
Author

all the integration does is... add the htmx script tag before initialisation

So.. what if we maintain an object with extension names & their urls like this

type ext = 'client-side-templates' | 'json-env' | 'ws' // ... all extensions available by htmx

const url = `https://unpkg.com/htmx.org/dist/ext/${ext}`

and then import it in the script tag the same way u add a script tag for htmx code.. in this integration

@xstevenyung
Copy link
Owner

I think this is going outside of the scope of this extension as this is using remote scripts.

If anybody needs HTMX extension, feel free to opt-out of astro-htmx and import it on your own

@gedw99
Copy link

gedw99 commented Jul 4, 2024

@xstevenyung

But htmx 2.0 leans heavily on extensions such as ws, sse and a ton of there things. So with supporting extensions this astro extension becomes very limited if not useless.

@RayyanNafees
Copy link
Author

RayyanNafees commented Jul 9, 2024

I think this is going outside of the scope of this extension as this is using remote scripts.

What else u think is happening here ?

the script is actually remotely fetched from npm registry when we use unpkg.com.

In case u need npm-packages for imporing the extension are available as npm packages by user @carsongross

While adding extensions as dependencies might not be the ideal approach to go with... since it might bloat the integration with htmx extensions the developer might not need...

But having a way to integrate these with astro-htmx would be really helpful

@xstevenyung
Copy link
Owner

What else u think is happening here ?

@RayyanNafees there is a clear distinction between installing and bundling your own dependencies and serving from a CDN.

I will dig to find a proper solution but I don't think mixing bundled deps and CDN assets is the right call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants