HTMX vs AlpineJS - Which should you use for your web app?

Поделиться
HTML-код
  • Опубликовано: 4 ноя 2024
  • НаукаНаука

Комментарии • 75

  • @KeithRobinsonOmaha
    @KeithRobinsonOmaha 9 месяцев назад +8

    Pleasantly surprised by your insight and delivery. Very articulate, and well thought out. I love finding new channels that are immediately valuable. Looking forward to watching this channel grow.

    • @HAMYLABS
      @HAMYLABS  9 месяцев назад

      Thank you for watching and glad you found it valuable!

  • @markvanbeek3338
    @markvanbeek3338 3 дня назад +1

    came across this vid and was pleasantly surprised, thanks for the clear explanation. I like your minimal basic approach i'm an advocate of that too...

  • @MichaelHughes124
    @MichaelHughes124 6 месяцев назад +13

    This deserves more views. Very helpful overview. Web dev doesn’t have to be so complicated!!

  • @BosonCollider
    @BosonCollider 7 месяцев назад +7

    I personally really like the new Alpine Ajax plugin. Basically it extends alpine to include the HTMX functionality in a more integrated way, and adding only 3 kB to the bundle size instead of 13 kB if you had alpine either way

    • @HAMYLABS
      @HAMYLABS  7 месяцев назад

      Yeah just saw this earlier today - looks very clean and quite a bit simpler.
      Might try it out in a future project

  • @robrobob
    @robrobob 5 месяцев назад +9

    For high-speed rendering, htmx has a websockets extension you can use, so you're not making a brand new connection for every request. It may not be suitable for every use-case, but definitely something to look at if you're using htmx and you need much faster client/server interaction.

  • @sulaimanmisri6411
    @sulaimanmisri6411 26 дней назад +1

    Currently I'm using and combining HTMX with Alpine JS. It's so cool and easy to implement. Your insight convinced me that I'm not using the wrong combination. Haha!

    • @HAMYLABS
      @HAMYLABS  25 дней назад

      Awesome! Yeah I've found it to be a pretty simple and refreshing combo!

  • @constantine9074
    @constantine9074 9 месяцев назад +5

    This is exactly what i needed !! You helped me to determine my future for at least next 2 years... PHP LARAVEL HTMX ALPINE , I'll hang out with these nice guys

    • @RezaOpdebeeck
      @RezaOpdebeeck 4 месяца назад

      If you use Laravel, just add Livewire. It uses Alpine. You really don't need HTMX.

  • @JamesJosephFinn
    @JamesJosephFinn Месяц назад +1

    A true demonstration of deep knowledge on a topic is if you can explain it simply. Thank you. (Edit: Prime should do a reaction video!)

  • @duckeggcarbonara
    @duckeggcarbonara 5 месяцев назад +9

    Alpine AJAX is a very beautiful extension for Alpine that removes the need for using HTMX whatsoever for me personally.

    • @HAMYLABS
      @HAMYLABS  5 месяцев назад +2

      Yep - they both provide similar things, partial reloads controlled by server.

    • @tanko.reactions176
      @tanko.reactions176 Месяц назад +1

      its limited to forms. i like the flexibility of htmx.
      for me, its htmx + alpinejs!

  • @everyhandletaken
    @everyhandletaken 2 месяца назад +1

    I think I just watched Dan Levy talk to me about HTMX & AlpineJS here. Excellent!

  • @jordanstewart225
    @jordanstewart225 8 месяцев назад +3

    Showing a modal is easy with the new html tag. So you don't really need to much JavaScript for that

    • @HAMYLABS
      @HAMYLABS  8 месяцев назад

      Yeah looks like you can use the element's `open` attribute to open and close which is cool - like that we're doing more Hypermedia based controls!
      Interestingly MDN recommends using the JS functions to handle this rather than the attribute. No explanation why though - developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog

    • @jordanstewart225
      @jordanstewart225 8 месяцев назад +1

      @@HAMYLABS I think the `open` attribute opens it as a dialog, not a modal. I think that is the same as the `show()` javascript method. The `showModal()` opens it as a modal. The modal blocks everything else on the page if open.

  • @jimratliff
    @jimratliff 8 месяцев назад +1

    This was great. (Far better than ChatGPT's answer.) You super clearly identified how they are complementary (note spelling disagreement with your blog post). There are lots of RUclips that plunge into using both, but they don't provide a clear overview of (a) why use both? and (b) use which for what functionality? So count me as a new subscriber!

    • @HAMYLABS
      @HAMYLABS  8 месяцев назад +2

      TY for the kind words and glad you found it helpful!
      Oh no I realized I often spell complementary as complimentary -> I thought they were spelled the same =D

  • @getthedistortion
    @getthedistortion 4 месяца назад

    I was really confused about HTMX but it finally clicked. It actually seems super nice and simple after all. Great video. ++

    • @HAMYLABS
      @HAMYLABS  4 месяца назад

      Glad it helped!

  • @patrickambrosso
    @patrickambrosso 3 месяца назад

    Really good explanation, just what I wanted.

  • @haryormedayjoshua281
    @haryormedayjoshua281 4 месяца назад

    I love this and learnt a lot. Welldone.
    Though the two things I think are debatable and I don't really agree on are:
    1. Having a JS Framework doesn't lock you in to use technologies like NodeJS like on the backend. I build apps with these frameworks with frameworks like laravel and django also.
    2. No one is talk about some of the limitations of HTMX like scaling and needing to have server control. What happens when I need to integrate a 3rd party API and working with a team? JS Frameworks do these things better...
    3. Correct me if I'm wrong but HTML responses tend to be larger than JSON's
    I currently use AplineJS and HTMX in some projects but I still think it's worth really stating in videos such as this so we don't preach a convention or way of building web apps that is better then later down the line, start with "Ummm, Ok so that might not be the best way anymore..."
    Isn't that the case with rendering on the client vs rendering on the server, JS frameworks and so many other examples I can give....

    • @HAMYLABS
      @HAMYLABS  4 месяца назад

      Glad you found it useful and thanks for the details responses!
      > Stating in videos that this isn't the only way to build things
      Totally agree that there is no right way to do things - just a bunch of tradeoffs. The problem is if I said this in every video then it's basically just fluff - I've wasted 2 mins of people's time instead of just focusing on the thing I am presenting today.
      So this is also a tradeoff - I choose to try and make my videos focused on the technology at hand and assume that my viewers know that I am just a dumb guy on the internet and you need to make up your own mind ab this.
      > 1: JS Framework doesn't lock you into NodeJS on the backend
      So I agree that you can choose whatever you want on the backend and still use JS framework on the frontend. But usually the JS framework does involve NodeJS at some point.
      Q1: How are you using your JS framework of choice with Laravel / Django? In particular, what is compiling your JS framework of choice into usable HTML / CSS?
      In most cases I've seen this either as a separate frontend NodeJS monolith or many backend frameworks abstract this so they deal with the NodeJS integration themselves. But I don't use these much anymore so maybe I'm wrong.
      > 2: No one is talk about some of the limitations of HTMX like scaling and needing to have server control
      Q2: Why do you think HTMX reduces server control?
      I would think HTMX provides more server control than SPAs because everything is rendered on the server but curious to hear why you think it has less server control.
      RE: scaling - HTMX is MPA but with lighter reloads. MPAs have worked great for decades so this will scale better than an MPA at least perf wise. Maintainability wise is still to be seen.
      RE: 3rd party API - you would integrate the same way you do w JS. JS integrates w APIs via web requests. Your backend can do this too.
      > 3: HTML Responses are larger than JSON
      Sometimes. As always all approaches have tradeoffs. Both of these have ways that they are inefficient:
      * HTML - inefficient if sending lots of markup overhead (like tailwind styles tend to be hard to compress)
      * JSON - inefficient if you are overfetching / need to hit multiple APIs for a given page (like when you don't have a very flexible backend API surface)
      In both cases there are ways to mitigate.
      HTMX creator did a comparison of sizes and when both response types are compressed they are basically the same size - github.com/1cg/html-json-size-comparison
      But again there are ways to get both wrong and thus use inefficiently. I think time will tell if this is a widespread problem in production or not.

  • @Septumsempra8818
    @Septumsempra8818 8 месяцев назад +1

    I use both. I'd appreciate more vids on passing info/data between Alpine and HTMX.

    • @HAMYLABS
      @HAMYLABS  8 месяцев назад +2

      Ooh that's a good idea! I'll add to my list

    • @Septumsempra8818
      @Septumsempra8818 8 месяцев назад

      ​@@HAMYLABS I have a design pattern that I need help with. I have an ecommerce site and when a user adds to cart, the cart total badge in the top nav gets updates with an Html partial. However, when a user navigates back/history.push() they see the old cart total taken from cache. How do I retain the latest state even on history.push()?
      P.s anything on caching would be appreciated

  • @FUBAU
    @FUBAU 4 месяца назад

    Great video, thank you very much for your insight!

  • @CristianKirk
    @CristianKirk 4 месяца назад +1

    HTMX functionalities are incredibly useful and feel almost irreplaceable (except if you wanna deal with AJAX yourself) while AlpineJS is more like a modern jquery that's only useful for those who have a hard time using js to do basic manipulation of the elements in the DOM.

  • @westpoint7942
    @westpoint7942 8 месяцев назад

    Cool! Thank you, man!

  • @EricG-xk4el
    @EricG-xk4el 4 месяца назад

    Subscribed. Like your vibe, like your content.

  • @irlshrek
    @irlshrek 5 месяцев назад +2

    Id love to hear your thoughts on data-star. The creator in a way combined Alpine and HTMX in a really clean way

    • @HAMYLABS
      @HAMYLABS  5 месяцев назад +2

      Yeah I've been thinking ab playing around with the many alternatives out there to see how they work / tradeoffs:
      * datastar
      * alpine ajax
      * htmz
      * unpoly
      Probably more out there now too. Just haven't felt stuck / constrained w HTMX yet so haven't felt strong need but might get to it this summer

  • @rebresh58
    @rebresh58 7 месяцев назад

    Thanks, it was insightful

  • @guseynismayylov1945
    @guseynismayylov1945 6 месяцев назад

    You can just EHTML, which is awesome for static content like SVG, HTML, Markdown and also can work with dynamic JSON responses.

  • @JeremyMapalad-h4p
    @JeremyMapalad-h4p 4 месяца назад

    Great insights!

  • @user-ke8ty5ds7r
    @user-ke8ty5ds7r 7 месяцев назад +1

    Well, there is an ajax plugin for Alpine that looks quite sophisticated.

    • @HAMYLABS
      @HAMYLABS  7 месяцев назад +2

      Looks pretty cool - alpine-ajax.js.org/
      Seems like a slimmed down version of HTMX by design. Could definitely see this being a good way to go

  • @FirdausAziz
    @FirdausAziz 5 месяцев назад +1

    My favorite combo is HTMX and HyperScript.

    • @HAMYLABS
      @HAMYLABS  5 месяцев назад

      I hear it plays nicely together!

  • @hipertracker
    @hipertracker 2 месяца назад

    60fps iin the browser s not a problem for server side rendering if you use Phoenix and LiveView :) LiveView is a lot faster than HTMX since it uses websockets to transmit a tiny diff values between the server and the browser.

    • @HAMYLABS
      @HAMYLABS  2 месяца назад

      Interesting - do you have examples where they're doing that in a game or similar?
      I've seen demos where 60fps if possible but never a project that actually uses it so curious if you have one.

    • @hipertracker
      @hipertracker 2 месяца назад

      @@HAMYLABS high-performance games require a lot of CPU power, so they need C++, not Elixir. Phoenix shines and is great for real-time, fault-tolerant websites, which are its target, and its LiveView is obviously faster than HTMX. However, it is bound to Elixir and BEAM, while HTMX can work with any server-side technology. There is no silver bullet.

  • @mr_don_key
    @mr_don_key 8 месяцев назад

    i've seen games build with liveview (same kind of thing like htmx), and it was fast.... (so the argument of not using htmx, when "when your app doesn't need complex, high speed rendering" is not necessarily true)

    • @marcelaodev
      @marcelaodev 5 месяцев назад

      it's fine as long as internet is stable

  • @mr.random8447
    @mr.random8447 8 месяцев назад +1

    Can you do tutorial Rust + HTMX + AlpineJS

    • @HAMYLABS
      @HAMYLABS  8 месяцев назад

      I don't do much Rust myself but might play w it in future.
      Q: Is there something specific you're curious ab building w Alpine + HTMX?

  • @JamesJosephFinn
    @JamesJosephFinn Месяц назад

    It should be mentioned that the HOWL Stack acronym is the brain child of Carson Gross.

    • @HAMYLABS
      @HAMYLABS  Месяц назад

      Yep - his essay is very good.
      HOWL (Hypermedia on Whatever You Like) - htmx.org/essays/hypermedia-on-whatever-youd-like/

  • @SpeedCodes-oc7ed
    @SpeedCodes-oc7ed 8 месяцев назад

    do you have a course for alpine and htmx together?

    • @HAMYLABS
      @HAMYLABS  8 месяцев назад +2

      No course yet but been thinking about making some videos about them.
      Q: Anything you're stuck on / would like to learn about for building with HTMX and Alpine?

  • @JonasThente-ji5xx
    @JonasThente-ji5xx 8 месяцев назад

    wow rhis is epix

  • @LiveErrors
    @LiveErrors 9 месяцев назад

    How does Alpine compare to Petite Vue?

    • @bartek.igielski
      @bartek.igielski 9 месяцев назад +2

      Besides Petite Vue being a dead project, it's more skewed towards using JS, not avoiding using JS, but still, you can do most of the things almost the same way as in Alpine.
      It is lighter, but has less QOL things like built-in transitions, and there are like 0 plugins for it, since it never gained traction.
      What Alpine is missing, are reusable UI components (you can just reuse logic, but no templates), but due to the nature of using those libs usually with some backend framework that can handle the component for you, it's not that big of a deal.

  • @ignaciobeltran7882
    @ignaciobeltran7882 4 месяца назад

    can i use both?

  • @smyrnian_
    @smyrnian_ 8 месяцев назад

    They are not complimentary if you use Alpine-ajax (you don't need HTMX).

    • @MarkVolkmann
      @MarkVolkmann 6 месяцев назад

      Alpine-ajax is cool, but not as capable as htmx. htmx has way more features.

  • @JeremyAndersonBoise
    @JeremyAndersonBoise 3 месяца назад

    Both, 2EZ

  • @zainali501
    @zainali501 5 месяцев назад

    Make a video on lit.js vs alpine.js

  • @retakenroots
    @retakenroots Месяц назад

    none of both?

  • @enriquebruzual1702
    @enriquebruzual1702 5 месяцев назад

    There is no "Vs." Alpine complements HTMX

    • @HAMYLABS
      @HAMYLABS  5 месяцев назад

      Yes - that is the point of this video =)

    • @enriquebruzual1702
      @enriquebruzual1702 5 месяцев назад +1

      @@HAMYLABS then don't use "vs" in the title, subscribed ;-)

  • @ScriKidding-eg6vn
    @ScriKidding-eg6vn 9 месяцев назад +1

    htmx is good until you hit interactivity problem Muahaha let's go SvelteKit!

    • @MarkVolkmann
      @MarkVolkmann 9 месяцев назад +4

      That’s what you get by adding the use of Alpine.

    • @axMf3qTI
      @axMf3qTI 9 месяцев назад

      What?

  • @shao7620
    @shao7620 9 месяцев назад +2

    Why not both?

  • @bokunochannel84207
    @bokunochannel84207 2 месяца назад

    i disagree. alpine works better than htmx even if you do need to pull or push data, to or from the server.
    handling network error or http errors from html attributes is a nightmare. meanwhile, alpine is basically JS in html attributes. it uses `eval` under the hood.
    alpine make sense when you want to make something small and simple with little bit of reactivity.