HTMX in 60 seconds with ThePrimeagen

Sdílet
Vložit
  • čas přidán 8. 09. 2024
  • Full Course: HTMX and Go buff.ly/3PupYLL
    About this Course:
    Are you wanting an alternative to complicated UI frameworks? Make web app development simpler using HTMX! Using Go, you’ll build a simple server to respond to routes with templates. Then enhance your HTML with HTMX attributes to target updates on parts of the page. Tackle error handling, out-of-band updates, and advanced patterns for URL control and redirection. Learn the grug way (it’s just HTML, btw) for building interactive web experiences!
    Find Frontend Masters Online:
    Twitter: buff.ly/3THunx7
    LinkedIn: buff.ly/3zCEok4
    Facebook: buff.ly/3TrYeZl
    Instagram: buff.ly/3IHdxZh
    About Us:
    Advance your skills with in-depth, modern front-end engineering courses - our 200+ high-quality courses and 18 curated learning paths will guide you from mid-level to senior developer! buff.ly/3TItGnl

Komentáře • 180

  • @j.7156
    @j.7156 Před 2 měsíci +185

    I've never felt so old as I do reading these comments acting like the server returning HTML is a radical new idea.

    • @c11r11
      @c11r11 Před měsícem +4

      Back to 2008!

    • @justchary
      @justchary Před měsícem +13

      I guess the difference here is that in HTMX server returns HTML only of the element being changed, not the entire page, like in year 2000

    • @petrlaskevic1948
      @petrlaskevic1948 Před 28 dny +1

      ​@@justcharythis is similar to framesets

    • @christophfischer2773
      @christophfischer2773 Před 17 dny

      i am confused. Is this not an introduction to REST?

  • @InvaderZae.
    @InvaderZae. Před 5 měsíci +316

    As I watched this video, I stared intently at the screen. I nodded my head in understanding. I let out a "Mhm". As the end came near, I sat back and exhaled, knowing full well, I understood none of that.

    • @--bountyhunter--
      @--bountyhunter-- Před 4 měsíci +7

      lol
      well, what he SAID is quite easy to understand
      in simple term, basically with htmx u don't need JS to work with API, htmx lets u ask for more html content from the server , and once server sends back the html content, htmx lets u do tons of things with the returned html

    • @laughingvampire7555
      @laughingvampire7555 Před 4 měsíci +1

      @@--bountyhunter-- you have always been able to that, you don't need htmx, you can do it without htmx, that is how people did it back in the 1990s and in the 2000s & early 2010s with jQuery.
      And people switch from that to using JSON for a reason, JSON allows you more flexibility.

    • @--bountyhunter--
      @--bountyhunter-- Před 3 měsíci

      @@laughingvampire7555 what I said was , using htmx u don't need JS to communicate with server for html content.
      you said we were always able to do that. then proceeded to mention using jQuery, which is basically JS xD.
      Basically u said we were always able to omit JS and communicate with server for more html contents with JS. xD

    • @dean.b
      @dean.b Před 3 měsíci

      @@laughingvampire7555 correct, but HTMX makes it easier. people decide to use libraries and frameworks because they make things easier. HTMX does that.
      JSON allows more flexibility, sure. But we've seen that in real applications, using JSON APIs results in extremely bloated responses (ie, frontend applications requesting an entire "get user" API endpoint just to get the user's display name).
      Using HTMX (or really any form of true SSR framework), you don't encounter this issue because the only things that are transferred "over the wire" are UI primitives. You still get the flexibility of being able to call a "get user" endpoint/function, but the only thing sent over the wire is the display name, rather than the entire user object. (As an additional benefit it's a lot easier to optimize code like this on the backend, since you're actually able to do things like writing custom SQL queries that only get the info that you need, instead of needing to write an entirely new endpoint that gives you the info you want)
      Anyway sorry for all the yapping. Just an SSR fan, and I like the way HTMX approaches it since it's interactive SSR without framework lock-in.

    • @gandalfthegrey2777
      @gandalfthegrey2777 Před 3 měsíci

      ​@@laughingvampire7555but htmx clearly is an upgraded version of it, a better way to do it.
      This method wasn't good enough so we got the front end framework wars but now htmx is actually a considerable replacement for descent sized responsive applications competing with those frameworks

  • @tamesb
    @tamesb Před 2 měsíci +15

    I am so happy you are bringing HTMX to the general public this way, I've waited for this for years

  • @JustinLietz
    @JustinLietz Před 4 měsíci +30

    That’s actually really cool and useful, if I’m understanding this right it reduces a lot of the work on the client side

  • @marccawood
    @marccawood Před 18 dny +3

    I’m waiting for iFrames to come back in fashion. They’re awesome.

  • @ben.daniel
    @ben.daniel Před 2 měsíci +5

    This is the perfect elevator pitch for HTMX. I like it.

  • @JhonatanMorais
    @JhonatanMorais Před 4 měsíci +21

    I CAN'T believe on this... OMG... first server side rendering is back... now HiperMedialink and template system is back... unfortunately large usage of xml is the next... prepare your self new generation... hahah

  • @Xaero324
    @Xaero324 Před 3 měsíci +11

    This is funny as I did this back in the day with jQuery 😅.

  • @PostMeridianLyf
    @PostMeridianLyf Před 5 měsíci +168

    Ah. So I don't need react?

  • @Leonhart_93
    @Leonhart_93 Před 3 měsíci +22

    Ah, so we went back to the good ol' days of serving and replacing some html with some Ajax request.

    • @soueucaasii
      @soueucaasii Před 14 dny

      i knew i've seen this formula before loool

  • @SilverPaladin
    @SilverPaladin Před 23 dny

    HTMX is full circle. I love it!

  • @carleguii
    @carleguii Před 4 měsíci +14

    Isn't that Ajax/partial render? 🤔

    • @PaulPendor
      @PaulPendor Před 4 měsíci +13

      Or as we called it back in the late 90s / early 2000s DHTML Dynamic HTML. All similar concepts wrapped up in libraries and frameworks.

    • @LZE.
      @LZE. Před 3 měsíci +1

      Yep. Exactly what we were doing 20+ years ago.

  • @rs832
    @rs832 Před 3 měsíci +2

    @FrontendMasters you should be linking the course & pinning the comment.

  • @holetarget4925
    @holetarget4925 Před 18 dny

    HTMX is very beautiful 🤩

  • @JohnMeathead
    @JohnMeathead Před 5 měsíci +51

    Say no to WebDev
    Console windows and manual curl requests rule!

    • @sohigh7433
      @sohigh7433 Před 4 měsíci +8

      Just serve it on port 8000 using netcat 💪

    • @philstanton8912
      @philstanton8912 Před 4 měsíci +1

      @@sohigh7433you sir, are a chad

    • @neoqueto
      @neoqueto Před 2 měsíci +2

      And then you become a specialist at what you just described and boom, Postman is created.

    • @hackmedia7755
      @hackmedia7755 Před 8 dny

      if you want to go hardcore, use C++ and wireshark.

  • @almondjoy112
    @almondjoy112 Před měsícem

    Feeling very apollo guidance computer with that "verb" reference.

  • @moumous87
    @moumous87 Před 3 měsíci +1

    That stache 🫡

  • @axryuk
    @axryuk Před 2 měsíci

    That stache is juts 😂 love it

  • @scottspitlerII
    @scottspitlerII Před měsícem +1

    God, what a magical mustache

  • @specimen532
    @specimen532 Před 11 dny

    What's the hood for?

  • @hackmedia7755
    @hackmedia7755 Před 8 dny

    does it result in less code or more frustration?

  • @mollistuff
    @mollistuff Před měsícem +1

    What's the difference between this and jQuery?

    • @anotherelvis
      @anotherelvis Před měsícem +4

      I think that the difference i that the developer does not write any javascript. Everything is declarative.

  • @nykowow
    @nykowow Před 5 měsíci +2

    How do you manage meta tags like "description"?

    • @programmers_sanctuary
      @programmers_sanctuary Před 4 měsíci +4

      The current version only supports title tags, but there's an extension called head-support

  • @I_Lemaire
    @I_Lemaire Před 3 měsíci

    Go Prime!

  • @Joshua.Developer
    @Joshua.Developer Před měsícem +2

    99% of the time you dot need React. Unless your building say Spotify 2

  • @Marco-Vavassori
    @Marco-Vavassori Před 5 měsíci +13

    The problem is that it works just if you plan to make a website. Otherwise you'll have to make multiple apis; you can't serve html to a mobile app.

    • @jacobblomquist5288
      @jacobblomquist5288 Před 5 měsíci +15

      Just make one API with different behavior dependent on the `accept` header.

    • @jay0001112
      @jay0001112 Před 4 měsíci +4

      It’s not two different API’s though. It’s an API for non web apps and html/fragments for the web app. You are replacing front end code with back end code for the web app. It is still far less code.

    • @ScrotoTBaggins
      @ScrotoTBaggins Před 2 měsíci +2

      Nonsense

    • @paperclip11
      @paperclip11 Před měsícem

      Nah man. Make a PWA by adding a service worker. iOS not supporting them fully is a sin, but can do most things on android.
      If not that, wrap the site in one of the mobile wrapper libs.

    • @fullfungo
      @fullfungo Před 29 dny

      What you said makes 0 sense.

  • @georgezimmer5622
    @georgezimmer5622 Před 3 měsíci +3

    Is this comment section full of zoomer or what ? Don't worry guys, you'll learn what a monolith is when node circle back to it in about a year.

  • @gusthomas6872
    @gusthomas6872 Před 4 měsíci +1

    is htmx REST compliant?

    • @AgustinAbusleme
      @AgustinAbusleme Před 4 měsíci +12

      yes this is actually more REST compliant than react since it uses HATEOAS, a requirement of the original idea of a RESTful web that later for forgotten because it was impossible to do due to the amount of js and state added to the client side

    • @marccawood
      @marccawood Před 18 dny +1

      Most REST APIs aren’t REST compliant

  • @dirty-kebab
    @dirty-kebab Před 5 měsíci

    I actually fully understand this. I want to swap from Webpack to Bun... Maybe HMTX. Need a NoSQL server too

    • @bthero03
      @bthero03 Před 4 měsíci +2

      Moving on from Webpack makes complete sense, but why would you need to go for NoSQL? Just wondering

  • @PhilippBlum
    @PhilippBlum Před 3 měsíci

    I assume htmx also works with HTTP3?

  • @guseynismayylov1945
    @guseynismayylov1945 Před 4 měsíci

    Or you can just use EHTML with JSON response and handle 404 and other statuses. It also quite flexible because of templates

  • @FikriHaikal-he4bg
    @FikriHaikal-he4bg Před 3 měsíci +3

    Shit, i had 201 status code

  • @sergey5758
    @sergey5758 Před 5 měsíci +4

    it’s looks like a bad idea to mix view layer and api layer. What if I need to combine several requests together to get full info before render it? I guess I should use “custom events” with custom handler or something like that ,
    but it lead us to react-ish way. I think htmx will works for static landing pages, not for big apps

    • @semsem7609
      @semsem7609 Před 4 měsíci +11

      There is a difference between hypermedia apis and data apis.

    • @programmers_sanctuary
      @programmers_sanctuary Před 4 měsíci +1

      You can always use specific endpoints for specific stuff. The good thing about HTMX is that you can use it anywhere.

    • @VelvetSage
      @VelvetSage Před 4 měsíci

      BFF

  • @byronjones5902
    @byronjones5902 Před 2 měsíci +2

    The advantage of Json is that you can render the same data set in multiple ways on the same UI. I can’t see how this isn’t a huge step backwards - is bandwidth and computing time free now?

    • @darylbarnes9413
      @darylbarnes9413 Před 22 dny

      That’s what CSS is for. Most React developers are clueless when it comes to CSS though and have to rely on something like Tailwind which handicaps them from being able to fully take advantage of a truly RESTful API solution like you can do with something like HTMX and all the advantages that offers over JSON apis with REACT.

  • @laughingvampire7555
    @laughingvampire7555 Před 4 měsíci +3

    one of the reasons that people abandoned emitting html from the backend is because companies always like to change style of the website and you are not going to tell "duuuhhhh, I need to rewrite the whole thing"

  • @Canilho
    @Canilho Před 3 měsíci +3

    How is this any different from XML HTTP Requests launch from JavaScript.

    • @Sandromatic
      @Sandromatic Před 3 měsíci +4

      It literally does that, yes. The point is that it's not JavaScript you have to write for basic things like that, just a couple of attributes in your html.

    • @Dieterbe
      @Dieterbe Před 3 měsíci

      ​@@Sandromaticdoesn't that put us back in the state management mess? The whole reason we realized we needed something like angular or react?

    • @mikadofxx9030
      @mikadofxx9030 Před 2 měsíci +4

      ​@@Dieterbewe are not in state management mess now with SPA frameworks?

    • @luka1790
      @luka1790 Před 2 měsíci

      ​@@mikadofxx9030it really depends how you build things

    • @rafaelrosa3841
      @rafaelrosa3841 Před 22 dny

      ​@@mikadofxx9030yes, we are.

  • @drregron2721
    @drregron2721 Před 2 měsíci +1

    If someone was playing much and had 0 mana, would the same thing happen or would they still bounce off?

    • @redpepper74
      @redpepper74 Před 25 dny

      Lmao wrong video

    • @drregron2721
      @drregron2721 Před 25 dny +1

      @@redpepper74yeah what the hell lmao - it commented on the other aswell though so that’s wierd

  • @aymanimtyaz8529
    @aymanimtyaz8529 Před 4 měsíci

    Doesn't this tightly couple frontend html to backend routes.

    • @AmxCsifier
      @AmxCsifier Před 4 měsíci

      it's a joke

    • @niblet8955
      @niblet8955 Před 4 měsíci +3

      No lmao htmx is very real

    • @AmxCsifier
      @AmxCsifier Před 4 měsíci

      @@niblet8955 htmx is a meme lol

    • @soft6418
      @soft6418 Před 4 měsíci +1

      Yes

    • @ben.daniel
      @ben.daniel Před 2 měsíci

      I've yet to see an example where that's not the case.

  • @ffelegal
    @ffelegal Před měsícem

    How different this is from php + ajax? 😅

    • @fullfungo
      @fullfungo Před 29 dny

      It doesn’t use PHP

    • @ffelegal
      @ffelegal Před 29 dny

      @@fullfungo no shit Sherlock

  • @joseluismoreyrajr.7598
    @joseluismoreyrajr.7598 Před 3 měsíci

    Sounds like turbo frames/streams to me. LLRoR

  • @abzz1290
    @abzz1290 Před 4 měsíci

    my brain : moye moye

  • @lachidong7818
    @lachidong7818 Před 4 měsíci +1

    I I have understood but still trying to centre that dam div

  • @dejohnny2
    @dejohnny2 Před 2 měsíci

    I can do this with old javascript. 😅

  • @seheyt
    @seheyt Před 4 měsíci +1

    I hope this only used with HTTP/2 or HTTP/3. Man.

  • @dmitriyobidin6049
    @dmitriyobidin6049 Před 4 měsíci +4

    But it's really doesn't show how to solve problems that facebook tried to solve with react - multiple updates in multiple places within a single requests.
    This example only shows that we can swap 1 html block at a time. What if we need to change our UI in multiple places, with different html blocks?

    • @kylelaker539
      @kylelaker539 Před 3 měsíci +1

      He said you can use a script so i guess you tell the script what your ui would be like?

    • @digvijayad
      @digvijayad Před 3 měsíci +1

      You can do that too. Look for "out of band swap" in the docs.

    • @dmitriyobidin6049
      @dmitriyobidin6049 Před 3 měsíci

      @@digvijayad But you can't be sure what elements a visible or not currently in the browser. Cause user could open some tabs or modals through client side scripting.
      Or you should track state of ALL user clicks on the frontend, which will be the same pain in the ass, but on the backend now... Complexity is still there. Nothing changed. But now your HTML coupled with backend logic. Nice decision.

    • @ben.daniel
      @ben.daniel Před 2 měsíci +5

      I'd say that if you have the problem that Facebook solves with React then use React. The point here is that most of the time you probably don't need React.

    • @darylbarnes9413
      @darylbarnes9413 Před 22 dny

      @@dmitriyobidin6049why would the user open tabs or modals through client side scripting when that should be done with HTML. You don’t need js for that. But yes HTMX is somewhat lacking in that although there are workarounds and extensions for handling those situations with vanilla js always an option as well. HTMX is not a full solution out of the box for everything it’s just a better solution for what js heavy frameworks are most often used for.

  • @DaWizardOfOz7
    @DaWizardOfOz7 Před 3 měsíci +1

    So where are the html files and stylesheets stored? Please don't say in the API codebase.

  •  Před 2 měsíci +1

    Sounds like a very chatty server-rendered UI.
    Are there any implications for slower network connections?

  • @卛
    @卛 Před 4 měsíci +3

    Nah, how about a fetch request and setting innerHTML

    • @switchlyrics.
      @switchlyrics. Před 3 měsíci +1

      hahaha i was thinking the same as u

    • @ben.daniel
      @ben.daniel Před 2 měsíci

      You've accurately described what this does.

    • @martinkrauser4029
      @martinkrauser4029 Před 29 dny +1

      just why. like. why have that instead of a single element attribute.

    • @fullfungo
      @fullfungo Před 29 dny +1

      That’s exactly how it works. Don’t reinvent the wheel

  • @tarquin161234
    @tarquin161234 Před 2 měsíci +1

    What's the point?

  • @hakimramzani9174
    @hakimramzani9174 Před 3 měsíci

    i am still using jquery load for my development 😂

  • @londonguga
    @londonguga Před 4 měsíci +1

    So far every video i saw about htmx only had fetch requests... and I think is silly returning an html from an api endpoint ...

    • @JordanHershberger
      @JordanHershberger Před 4 měsíci +1

      You should look at the docs then to see all of its functionality. It supports all http verbs and has a lot of really cool stuff once you start looking into the more complex interactions you can setup

    • @londonguga
      @londonguga Před 4 měsíci

      @@JordanHershberger I get that it has got more features, but most tutorials/articles about it explains on how to use fetch requests. Had look at the documentation and to be honest with you, apart from the hype of a new library in town, I really don't see any benefits of using this over already existing solutions

    • @programmers_sanctuary
      @programmers_sanctuary Před 4 měsíci +1

      Not really, you can do websockets/sse as well. At the end of the day, HTMX is just what we would probably write ourselves if we needed its functionality.

    • @jeffreysmith9837
      @jeffreysmith9837 Před 4 měsíci +2

      ​@@londongugabenefit is you get an SPA-like thing that's really optimized for SSR without doing the slow hydration bullshit

    • @anthonyewell3470
      @anthonyewell3470 Před 4 měsíci +2

      @@londonguga Benefits of HTMX, It's 10k, you decide what language you use for the server, It's framework agnostic (you can use svelte or react if you really want), the server is the only place of truth (this means it's easier to reason about what's happening)

  • @soft6418
    @soft6418 Před 4 měsíci +1

    We’ve gone full circle back to php

  • @shishsquared
    @shishsquared Před 25 dny

    Ahhh php

  • @gg-rf4ym
    @gg-rf4ym Před 2 měsíci +1

    So it’s the same thing with extra steps…

  • @fabianramirez3222
    @fabianramirez3222 Před 2 měsíci

    No real advantage on using htmx if it feels like what dynamic web pages used to do 20yrs ago.

  • @amirholmes3196
    @amirholmes3196 Před 28 dny

    I would use vanilla JS or JQuery instead of this nonsense. People here acting like all developers who hate htmx are react devs. No actually I am not a react dev. They say HTMX is for simple apps. I think JQuery is great for simple apps

  • @rahulbismarck
    @rahulbismarck Před 4 měsíci

    Why does this guy needs to have a hood on when talking about htmx ? Is it cold there ?

  • @ScrotoTBaggins
    @ScrotoTBaggins Před 2 měsíci

    Dude stop with the htmx

    • @fullfungo
      @fullfungo Před 29 dny

      No

    • @ScrotoTBaggins
      @ScrotoTBaggins Před 28 dny

      @@fullfungo Pretty please?
      Lol
      What's worse than backend platforms for frontend developers? (Node) Frontend nonsense for backend devs
      Just my opinion
      Go forth and do what you do
      I care not

  • @Dieterbe
    @Dieterbe Před 3 měsíci

    Sounds like spaghetti code. The whole reason angular and then react were invented ?

    • @fullfungo
      @fullfungo Před 29 dny

      Nothing is spaghetti about it.
      Care to elaborate?

  • @TheDrokon
    @TheDrokon Před 2 měsíci

    Only do this if you're DEFINITELY sure your app won't need a mobile app

    • @fullfungo
      @fullfungo Před 29 dny

      This has nothing to do with mobile.

  • @user-bu7ck7cm9j
    @user-bu7ck7cm9j Před 2 měsíci

    come on htmx sucks

  • @tooManyMidgets
    @tooManyMidgets Před 2 měsíci

    Yuck

  • @vteckickedin2365
    @vteckickedin2365 Před 4 měsíci +1

    Primagen is all about lower level performant code than actually building stuff quickly. Just use react with nextjs and get ur work done no one wants to do more work than they need to lol

  • @GrimaldGorb
    @GrimaldGorb Před měsícem

    is theo telling the truth about prime that he was fired from netflix because he supporting htmx, or is that just a sarcasm?

    • @redpepper74
      @redpepper74 Před 25 dny

      No lol he quit of his own volition to work on his yt channel
      Theo isn’t a great source of info anyway imo

  • @daneru
    @daneru Před 3 měsíci

    Nah, building html on the backend is considered out of date rn.

    • @vaisakhkm783
      @vaisakhkm783 Před 3 měsíci +4

      are you leaving in 2023 or something? Now everyone generating html on sever side with server side rendering...
      react server components, sveltekit renders everthing server side by default
      :) we came a full circle..

  • @kasper369
    @kasper369 Před 5 měsíci +6

    Feels like Htmlx is for boomers who don't want to learn React

    • @anthonyewell3470
      @anthonyewell3470 Před 4 měsíci +1

      You can use React and HTMX together, it doesn't care how you make the html, just that it's sending down html

    • @rahulbismarck
      @rahulbismarck Před 4 měsíci +3

      Yeah, like React is the answer to everything for non-boomers.
      "learn React", as if it was something…

    • @Gnaritas42
      @Gnaritas42 Před 4 měsíci +4

      React is hot garbage, as are all client side view frameworks. Server side rendering is far superior always has been and always will be. Only the young and inexperienced who got stuck on the hype train like and prefer react. Doing anything in react is 10 times as much work as doing it on the server, Modern responsive, dynamic single page applications do not require react. React is the Britney Spears of frameworks, just because it’s popular doesn’t mean it’s good.

    • @Gnaritas42
      @Gnaritas42 Před 4 měsíci +2

      @@rahulbismarck it's all they know; they have no idea they've learned "a way", not "the way" and they have no concept of history and the other 50 ways to build apps, many of them don't even know JavaScript, only React, it's really bad out there.

    • @Nomilh
      @Nomilh Před 2 měsíci +2

      @@Gnaritas42 As someone who's done Web in PHP with Symfony, Laravel, and a micro-framework i forgot the name, Python with Django and Flask, React and basic HTML / CSS / JS. Let me tell you, I would prefer to use React any day of the week. It is so much better to use React or any other JS frontend framework and create easy re-usable components than do templating.
      Don't get me wrong, React isn't the be all end all at all. For static pages it would be easier to use Wordpress, PHP or simple HTML/CSS/JS but for SaaS I would rather have a backend made in anything and a frontend in a framework like Vue / React / Angular than go back 10 years ago with PHP.
      Don't get me wrong, I have nothing against SSR, I just don't think the old way of doing UI is better than the new way. Next.js has the best of both worlds which I think will be the way forward unless something comes out that will make frontend frameworks obsolete

  • @ffh6795
    @ffh6795 Před 5 měsíci +2

    to me this sounds like frames... 🤷🏻‍♀️

    • @a6hiji7
      @a6hiji7 Před 5 měsíci

      Well, it's also JSP, PHP and many other Ps.

  • @s8x.
    @s8x. Před 4 měsíci

    responds with html? react don’t do that

  • @user-vl1bp3jj6p
    @user-vl1bp3jj6p Před 4 měsíci

    Bro needs to stay in his lane 😂