Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
imacrayon
searching Neon…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
5 ms
·
1.
▲
by
imacrayon
11mo ago
You can swap multiple elements with targeting too: `x-target="comments comments_count"`, but, yeah most of the time `x-sync` is better.
2.
▲
by
imacrayon
1y ago
This is the way. https://alpine-ajax.js.org provides what’s missing from HTMX.
3.
▲
by
imacrayon
2y ago
You made my day! thanks
4.
▲
by
imacrayon
2y ago
This is one reason I created https://alpine-ajax.js.org . A few years ago there were a lot of examples in the HTMX documentation that discouraged accessibility and progressive enhancement. Stuff like like clickable <div>s,
5.
▲
by
imacrayon
2y ago
I actually created https://alpine-ajax.js.org for this reason. HTMX and Hotwire both have opinionated requirements around the content and status codes that your server returns. One of the goals with Alpine AJAX is you should be
6.
▲
by
imacrayon
2y ago
There’s a draft proposal to get some of HTMX in the browser: https://github.com/alexpetros/triptych
7.
▲
by
imacrayon
2y ago
Help me understand why you need the JSON in these examples…You’re rendering JSON data on the frontend just to transform it into HTML. The HTML is rendered server-side, so you should be able to skip the JSON and embed the data in HTML, right
8.
▲
by
imacrayon
2y ago
Check out https://alpine-ajax.js.org it defaults to using the same template views you would in a typical JavaScript-less app, then you can sprinkle in fragments where you need to optimize requests.
9.
▲
by
imacrayon
2y ago
You can use https://alpine-ajax.js.org for this, or Alpine can work as an alternative to Stimulus.js in the Hotwire stack.
10.
▲
by
imacrayon
2y ago
There's some momentum around getting core HTMX functionality into the HTML spec so JS might not be required: https://www.reddit.com/r/htmx/comments/1ehjw7v/comment/lg09w...
11.
▲
by
imacrayon
2y ago
Alpine + Alpine AJAX. It's lighter than Alpine + HTMX and it doesn't require splitting your templates up into partials.
12.
▲
by
imacrayon
2y ago
Eleventy. It’s a static site generator that’s super stable, they take backwards compatibility very seriously so you can count on it for a long time. It’s lightweight so you don’t have to install a million dependencies to get it working, an
13.
▲
by
imacrayon
2y ago
I had a similar experience, so I took the stuff I liked from HTMX and made it into an Alpine plugin: https://alpine-ajax.js.org
14.
▲
by
imacrayon
2y ago
Oh, absolutely :) I try to keep up on Slack, but I need to get back to going to the in-person events again. It’d be cool to reconnect there sometime!
15.
▲
by
imacrayon
2y ago
I’m impressed with how thorough this is! It’s cool insight into the dev conference experience.
16.
▲
by
imacrayon
3y ago
Yeah, Alpine components have `x-init` that works just like the load trigger. You can fire off an AJAX request inside that directive, there's an example here: https://alpine-ajax.js.org/examples/lazy-load/
17.
▲
by
imacrayon
3y ago
Whatever floats your boat...I wish it supported comments though.
18.
▲
by
imacrayon
3y ago
It does a full page reload at the moment. I'm about to start work on a full SPA mode that will function more like Turbo though.
19.
▲
by
imacrayon
3y ago
Thank you! I really have tried to sweat those details, it's reassuring to hear that's coming through.
20.
▲
by
imacrayon
3y ago
Yes! You’ve reminded me that there’s some subtle gotchas when using HTMX server-side that are probably worth documenting too. For one, HTMX starts with the assumption that you’re returning HTML fragments, but not all templating languages ha
21.
▲
by
imacrayon
3y ago
HTMX actually has a good essay on the scale question: https://htmx.org/essays/does-hypermedia-scale/
22.
▲
by
imacrayon
3y ago
Haha you’re not wrong. I love jQuery, but Alpine’s declarative style feels better, and since we don’t have to worry about all the backwards compat we get a library that’s half the size of jQuery Slim.
23.
▲
Show HN: Alpine Ajax – If Htmx and Alpine.js Had a Baby
(alpine-ajax.js.org)
92 points
by
imacrayon
3y ago
|
25 comments
24.
▲
by
imacrayon
4y ago
Nothing, if it works for you great! I’ve found Alpine code to be more declarative and easier to reason about. Also, jQuery often requires you to write more code to do the exact same thing in Alpine. One thing jQuery does better is AJAX, Alp
25.
▲
by
imacrayon
4y ago
Chances are you’ll end up writing more than 10kb of custom JS to make your components work. Alpine comes with basic batteries already included.
26.
▲
by
imacrayon
4y ago
I’ve made an Alpine plugin that can do a lot of the common things Unpoly does: https://imacrayon.github.io/alpine-ajax/ I’m actively working on it and looking for feedback.