21 ms·
Htmx in a Nutshell
- recursivedoubts 4y agohowdy, I'm the creator of htmx, happy to talk about it
- sureglymop 4y agoTwo questions. What would you recommend to build the backend in, some language that can parse xml/html well? And second question, are there any more extensive examples such as working authentication?
- silver-arrow 4y agoThat’s part of the benefit of htmx and it’s hypermedia approach, you can build the backend in anything you prefer. Some like using language and frameworks that use templates. Others, like we do, used fairy basic HTML generation libraries. We love Clojure so we use the Hiccup library to generate HTML. We use the full power of clojure and functions to build reusable HTML type components and their fragments.
- amne 4y agohx-post .. what? hx-put .. what? hx-delete .. what? I stopped scrolling as soon as I noticed I have to ask myself what am I posting to this URL? Maybe digging deeper I could find the reference docs explaining in very vague terms where the payload is coming from. But this was supposed to be simple.
- whichdan 4y agohttps://htmx.org/docs/#parameters https://htmx.org/docs/#parameters Simple doesn't mean "I should be able to intuitively understand this with under a minute of reading"...
- amne 4y agoWith so many tools floating in this space the landing page MUST be clear enough. Sorry.
- recursivedoubts 4y agohere is the landing page: https://htmx.org https://htmx.org the link here is to the docs, which is more involved
- KyeRussell 4y agoThis project has seemingly picked up a bunch of traction. The number of times it has appeared on the front page of this website serves as some indication, as well as the plethora of conference talks. You seemed unwilling to put more than 2 minutes into looking at an example, or 10 seconds into checking what page you were on, yet felt that your experience warranted these dismissive comments which cumulatively proportionally surely took up just as much time. You aren’t acting in good faith. This doesn’t add to the conversation at all.
- strangus 4y agoI hate web dev, but this gives me hope.
- tiffanyh 4y agoWould you characterize htmx as the successor to AJAX?
- recursivedoubts 4y agoI would say htmx is how I think HTML should work as a hypermedia, to make it possible to build more interactive applications within that paradigm.
- deleted 4y ago[deleted]
- francoisdevlin 4y agoGRUG? Is that you?
- recursivedoubts 4y agowell of course I know him he's me
- decross 4y agoin a way, he's all of us
- agentwiggles 4y agothis grug much appreciate wise senior grug's advice. thanks for many laugh!
- francoisdevlin 4y agoYou need to start merchandising. Complexity very, very, bad.
- mhitza 4y agoQuick question, as it made me curious. Can I send the content that I want to swap to the server itself? Say I want to submit a form to the backend, will it only send form fields or is there a way to send the form html itself?
- recursivedoubts 4y agothat would probably be best accomplished w/ a custom htmx:configRequest handler: https://htmx.org/events/#htmx:configRequest https://htmx.org/events/#htmx:configRequest you could jam the outerHTML of the detail.target into the detail.parameters map, maybe based on the presence of an attribute...
- mhitza 4y agoI'm gonna make a note on that when I have cycles to burn to experiment with htmx. From my understanding of reading that section, parameters being a container of kv pairs, I'd have to hack on the internals of htmx for it to be able to send a pure string (not form/multipart) as the body of a post/put request. If I get around of experimenting with that, and it fits my flow, would that be something you'd accept back into the project as a contribution to the code?
- recursivedoubts 4y agoi don't think you'd need to hack the internals, you just hook into that event to do what you need: htmx.on("htmx:configRequest", function(evt) { evt.detail.parameters['my-html'] = evt.target.outerHTML; // or whatever } you can jump on the discord and we can help you out when the time comes: https://htmx.org/discord https://htmx.org/discord
- artificialLimbs 4y agoWhy would you do that? Curious about use case.
- mhitza 4y ago
- jonomacd 4y agoI love the model. I've been writing a golang app with the standard library template system and it works really well. One bit I've found slightly unintuitive is the swap and settled states. Took my a while to animate in a sidebar how I wanted. It was my fault for not groking it faster but perhaps some more examples or guides in that regard could be useful.
- recursivedoubts 4y agoi agree and here is a perfect place for you to contribute to the project! :)
- jonomacd 4y agoHa. Excellent point! I think I need to understand it better myself before I try to write something about it.
- recursivedoubts 4y agohey now, I didn't understand what I was doing when I started htmx either... not sure I do now, come to think of it
- soperj 4y agoHonestly, even starting writing about it will likely help you (and the person finishing it).
- BeefySwain 4y agoYou have mentioned here and in other places that you use HTMX + HyperScript in production. Curious what that looks like, is it part of consulting, a side business, a day job ?
- recursivedoubts 4y agoconsulting as a side gig of my day job, which is a CS prof
- can3p 4y agoHi, thanks for the libraries! When I started using them, one of the hardest parts was to actually have it imported and built with webpack, since the site focuses on cdn and webpack example is really brief. Same goes for hyperscript Do you see cdn as a preferred way of usage?
- recursivedoubts 4y agounfortunately I don't know webpack really well, although I'd love docs contributions on it if the existing docs aren't good
- efields 4y agoyou're not missing anything :-P there's a big distortion field around expectations vs reality with webpack.
- m4lvin 4y agoHow does error handling work? If I try to replace the content of some div with a reply I get using htmx, but the request fails or times out etc., what content is then put into the div? What if the reply is not valid HTML? Sorry for the newb and lazy questions.
- recursivedoubts 4y agohtmx doesn't do anything on an error by default, but you can override this behavior using the extensive event system it has: https://htmx.org/events/#htmx:responseError https://htmx.org/events/#htmx:responseError
- silver-arrow 4y agoIt’s pretty simple to use the htmx events on the Response to handle errors dialogs or other behavior
- spion 4y agoI've never used htmx, primarily because I like the concept of "components" so much. (They serve two needs - standardizing larger blocks of UI and encapsulating them with an alternative interface, and providing islands of rich interactivity) Is there any material on successfully combining htmx with web components? It doesn't look to me like the original design takes this possibility into consideration... (note: at a surface glance it doesn't look to me like components are in conflict with hypermedia - one could treat them as a side channel that "enhances" the standard set of elements)
- caseyf 4y agoI use Unpoly and not HTMX but similar idea, what you do for components entirely is up to you. My components look like this. The JS and CSS is included in the application's bundles. Ruby renders HTML on the server side. app/components/breadcrumbs - _breadcrumbs.scss - breadcrumbs_component.rb ... app/components/search_field - _search_field.scss - search_field_component.rb - search_field.js - selections.html.haml
- ColonelPhantom 4y agoI'm not sure if I've entirely grokked the idea of components, but can't you define them server-side? So write them as some template magic that creates the "inner HTML". Then you just need some HTMX to enable using the component in a richer way. It's not really Web Components as specified, but iirc those are generally pretty much JS-dependent? But hypermedia's reliance on server side rendering means that you can just move this logic to the server.
- yawaramin 4y agoWhy wouldn't htmx work with web components? It just does asynchronous fetches and DOM swaps. Web components are just pieces of DOM. There should be absolutely no issue with them working together?
- talideon 4y agoFirst, I'll preface this that what I'm about to write is meant as an endorsement of HTMX. What HTMX does should've been a W3C standard a decade ago, and I've my fingers crossed that some day I'll be able to do what I've done with jQuery and remove it. Thank you for pushing the state of the art forward in a meaningful (and RESTful!) way.
- recursivedoubts 4y ago:) agree 100%, htmx shouldn't have to exist!
- hexmiles 4y agoHi, on the subject of hypermedia: I recently saw your talk when you showed hyperview.org as an alternative to HTML for mobile use case. As someone who is very interested in the space, are there other hypermedia implementation (if is the right word) that you found interesting? Or do you have some pointer for those who want to explore this space? Personally I really want some kind of hypermedia framework for terminal application, since I often need to work with hardware (or bandwidth) where the only interface is a terminal, and I never feel productive with manually writing the application code, having to reimplement a new client every time. Also thank you for htmx, I started using for a couple of project, and it really is refreshing. Especially kudos for the various example, that really helped making it "click".
- recursivedoubts 4y agoheya, i don't know of any terminal-based hypermedia, but that's an interesting concept maybe gopher as a prototype example? adam stepinski (creator of hyperview) is one of the heroes of hypermedia in that he didn't just develop a hypermedia format but also developed a hypermedia client, and you need both for a proper hypermedia system so, I would say... maybe you are lookin' at the person in the mirror who is going to make that terminal app hypermedia?
- modernerd 4y agoIs htmx a good fit for Electron apps? Curious to know if anyone in the community is actively using it that way.
- recursivedoubts 4y agoi have heard that people are using it in electron, but it seems a little crazy to me
- Vohlenzer 4y agoDo you have any suggestions for or reference implementations of server code that works well with htmx?
- ksec 4y agoAnything we can do to push HTMX inside HTML5 and not as JS add-on?
- mvac 4y agoWhat’s the story for modals? Or multiple modals, navigating in them etc… Do you plan to take inspiration from Unpoly Layers (https://unpoly.com/up.layer https://unpoly.com/up.layer) or is it out of scope for htmx?
- leetrout 4y agoI am burnt out (but recovering!) with web dev and htmx is what I am using for my project. Django, DRF, Postgres, tailwind and HTMX. I am so tired of all the front end frameworks and all the complexity that gets added. At some point I think you need it and you get returns from it but hearing more people in the industry recognize and talk about how JS everything isn't always the answer gives me hope. I like what HTMX has to offer and I am excited to see it continue to get air time.
- dysoco 4y agoCurious at why are you using DRF with HTMX; isn't DRF more common when you need to return JSON for example and render in the frontend? Wouldn't returning Django templates to use with HTMX be the best option? Or is it for POST requests?
- leetrout 4y agoI still have some API things and I like the router and serializers.
- TechBro8615 4y agoDoes the server renderer call the API routes via HTTP, or does it have a more direct path to fetching the same data? If HTTP, what interface does it use - loopback or the public address of the server? In my experience this distinction has been a source of complexity in server-rendered apps that consume the same API as the client but at a different address, leading to problems like untrusted self-signed certificates, mismatching hostnames, and leaky proxy routes. Or perhaps none of your server rendered pages even call the API directly, and you just expose it for other clients?
- FlyingSnake 4y agoWeb isn’t the only interface. DRF might also serve REST API to mobile or webhooks etc.
- iamgopal 4y agoHTMX can be used with templates and JSON with extensions.
- donatj 4y agoMakes me smile because everything old is new again. This is very similar to features MooTools had like 10+ years ago before JSON took off big.
- hadnayeer 4y agoWow really? That's crasy!
- recursivedoubts 4y agoif you like the retro-vibe of htmx, you might also like my homage to HyperTalk, the scripting language from HyperCard: https://hyperscript.org https://hyperscript.org
- CharlesW 4y agoHey, I didn't know the same person made both of these! How close would you say HyperScript 0.9.7 is to production-ready?
- recursivedoubts 4y agoi'm using it in production and I don't expect any major breaking changes before 1.0 (H1 2023) i would stick with what it is designed for: light front end scripting, rather than writing a huge app in it, but within that domain I think it'll be pretty reliable
- spjwebster 4y agoMakes me smile too. Around 2008 while I was at Yahoo! I built a standalone library called Dhaka (literally stuck a pin in a map and used the place name as the project name) that did almost exactly this. It was used on a few of the EU sites but I left before I got chance to open source it. The problem I was trying to solve was eliminating a bunch of duplicate JavaScript that was essentially sending/fetching data to/from a remote source and inserting/replacing it into the current page.
- 4y ago
- hyuuu 4y agohow would htmx handle application like pages? for example, something along the lines of google spreadsheets? Where each cell is interactive.
- lowonkarma 4y agoNot a good fit for that. But you might be able to use HTMX on the settings page of that spreadsheet app.
- recursivedoubts 4y agohtmx (and hypermedia in general) isn't a good fit for an online spreadsheet: https://htmx.org/essays/when-to-use-hypermedia/ https://htmx.org/essays/when-to-use-hypermedia/
- mekster 4y agoIt would be nice if your pages are more tl;dr friendly than everything looking like part of a text book which exceeds the attention span to understand the page who's just getting into it.
- alexbezhan 4y agoI'm building a SaaS that looks a lot like spreadsheets, but more specialized for PPC managers (my customers). Doing it in htmx. Works great.
- candiddevmike 4y agohtmx keeps getting posted here and choosing it comes down to "do you trust that your user's internet is stable" IMO. For a lot of interactive web apps, the answer is no, and htmx is not a good fit.
- deleted 4y ago[deleted]
- Darmody 4y agoWhat does the internet stability have to do with htmx?
- deleted 4y ago[deleted]
- jonomacd 4y agoSPAs make tons backend calls to get data. This isn't particularly different. To me the main difference is it is hard to build an offline app out of htmx as compared to a SPA but so few webapps are offline anyway...
- qbasic_forever 4y agoI don't see why it couldn't be used in a PWA with a service worker providing offline HTML responses to hx directive elements though. You can see an example here that uses a WASM-based service worker (but you don't have to do that, it could just be plain old JS generating HTML): https://github.com/richardanaya/wasm-service https://github.com/richardanaya/wasm-service
- infogulch 4y agoCheck out the live demo! https://richardanaya.github.io/wasm-service/ https://richardanaya.github.io/wasm-service/ Last month I contributed the todos functionality to this project after it was submitted to HN. https://news.ycombinator.com/item?id=33228891 https://news.ycombinator.com/item?id=33228891 I think this is a great idea and could eventually enable htmx projects to transition from server-side-only to being a PWA with very little code changes (given the right backend). Unfortunately this particular implementation exhibits some blocking issues which I was not able to solve yet: 1. The Service Worker is eventually unloaded from memory, which means all data is lost because it currently stores everything in memory. This isn't a defect as much as it is lacking a persistence feature; this is a MVP (emphasis on minimal) after all. The most promising solution in my opinion would be to use the OPFS/File System Access API with SQLite, which is yet to be shipped in all browsers. 2. The bigger issue is that once the SW is unloaded it doesn't come back. The SW getting reaped after being idle is fine, that's part of the expected behavior. But there are no events or any other indication that it was disconnected, at some point it just stops intercepting requests. I don't know why. If anyone can chip in here to say why it does this and how I can detect or somehow restart SW fetch interception on demand I would be glad to hear it. ( For some more detail see the "# Remaining Issues" in my PR #5: https://github.com/richardanaya/wasm-service/pull/5 https://github.com/richardanaya/wasm-service/pull/5 )
- megaman821 4y agoI have been using HTMX with modal and drawer web components. It has been nice to specify interactive pieces of content in a nice declarative way.
- nikhilsimha 4y agoThis gives me hope for webdev. Long time infra guy who dreads any front end work with the other frameworks.
- qbasic_forever 4y agoMy only complaint with htmx is that it is _nearly impossible_ to Google search for info about it. You just get tons of noise from Google 'helpfully' deciding you really just want to search for 'html'. You need to search for "htmx" (including quotes) to find docs, articles, etc. about it.
- recursivedoubts 4y agoa known issue, but it was too good a name (and domain) to pass up! hopefully over time the problem will subside
- stronglikedan 4y agoI get decent results from Yandex by putting a plus before htmx ("+htmx") and excluding the results for html ("-html").
- geenat 4y agogoogle will catch up eventually as htmx gains in popularity.
- ferdowsi 4y agoI'm curious about htmx, but all of the HTML mini-syntax very similar in aesthetic to Angular 1.0, which was pretty quickly supplanted by React. What excites people about htmx? Do people like the mini-syntax but dislike the ceremony of state management?
- gryzzly 4y agocould these directives live in an actual js file so the html/templates stay dsl free?
- silver-arrow 4y agoHave been using htmx for a little over a year now, and I am so thankful for this library. It has simplified our development tremendously from ClojureScript / React to vanilla Clojure on the backend doing SSR of HTML with htmx HTML element attributes. All with 1 script tag that includes this wonderful library. Kudos to the creator of htmx! This is what hypermedia architecture with true HATEOAS is all about. It feels like we took a wrong turn a decade ago, and we have been trying to reinvent rich clients with JSON RPC designs from the 90s. It has resulted in too much churn and complexity IMO.
- bnert 4y agoDoing something similar with janet. Really does simplify so much, and being able to not have to worry about always translating json -> html via { insert SPA framework here } is a breath of fresh air.
- silver-arrow 4y agoAgreed that it is a breath of fresh air. It totally eliminates heavy complexity in the development environment and networking protocol layers. What makes me happy is that it completely reinvigorates the server side language you prefer to use.
- harryvederci 4y agoSame here, also using Janet + htmx!
- hipjiveguy 4y agoDo you mean this? https://janet-lang.org/ https://janet-lang.org/
- bnert 4y agoYes!
- mrits 4y ago
- cpsns 4y agoHTMX is awesome. In a world of front end frameworks I don't understand and frankly don't care to understand, it lets me write nice, interactive websites in a very simple way. I've normally extremely skeptical of anything like this, but HTMX just feels right when using it.
- rlawson 4y agohtmx like all great ideas seems obvious in retrospect. Why can't other html elements do what links and forms do? Htmx simplifying it all back down to html - I had that "of course!" reaction.
- jmull 4y agoIf I'm understanding this correctly, this is a front-end only framework... is that right? If so, what do people pair it with on the backend? I can see how this approach allows for much more dynamic pages with just static content, but what about when there is a database involved? Also, what do people use for "published" static sites (I mean where the site is static once published, but the publishing step can pull content from dynamic source. Not sure the common terminology for that, but in this case, there tends to still be app logic to be developed, but it's just executed at publishing time rather than run time.) I'd imagine a publishing framework that is htmx-aware/friendly would be powerful. Just curious how people round out the tech stack.
- recursivedoubts 4y agohtmx focuses on extending HTML as a hypermedia and, like HTML, can work with whatever backend can produce HTML, which is pretty much all of them. We call this the HOWL (Hypermedia On Whatever you'd Like) stack.
- kitsunesoba 4y agoI have yet to use it in anything, but conceptually I'm a fan of this kind of freedom of choice. It's always a bummer to see something that looks cool for frontend use and find that it's tied explicitly to a particular back end.
- decross 4y agohtmx is pretty agnostic with regard to the backend side of things. You can use anything you want, really. There are htmx extensions to Django and I am working on a similar one for Express. Basically, a very simple middleware to deal with custom request and response headers.
- jonomacd 4y agoI've been building a golang app that serves html via the go standard library template system. It works really well. You can define and execute templates inline so you can define entire pages in html and then wrap a "block" around any reusable bit that you want to serve up dynamically. Really easy to use.
- shireboy 4y agoI want to like - I feel like the frameworks are all too much ceremony now. You need to buy into a bunch of different build tools, a cli or two, and are left wondering "where is my app again?" I've tried htmx, though, and like the simplicity, but am not 100% sold. In the olden days, ASP.NET Web forms Ajax had "Update Panels", which were similar to this. You'd wrap a section of markup in an "Update Panel" and that made it refresh just that bit of the page while keeping the rest. The problem is your "api" then ended up being a bunch of pages that output html, and passing state was a huge problem. This seems better, but still similar concept. At the end of the day, I want my backend API to be restful json(or grpc, graphql) any client can consume. I want the client to be written with as few dependencies as possible. Maybe I'm misunderstanding though. Put another way: suppose I have an existing backend REST API where input/output is json. Can I use htmx without any changes to the api or server-side code to translate json to markup?
- recursivedoubts 4y agoHypermedia APIs and JSON (Data) APIs are different. I have a few essays up on these differences here: https://htmx.org/essays/hypermedia-apis-vs-data-apis/ https://htmx.org/essays/hypermedia-apis-vs-data-apis/ https://htmx.org/essays/splitting-your-apis/ https://htmx.org/essays/splitting-your-apis/ Generally, I would recommend splitting your data and hypermedia APIs up, so you can take advantage of the features of hypermedia (the uniform interface) and still provide a good data API to clients that want it. Also, this is pedantic, but a graphql JSON API is almost certainly not REST-ful, in the original sense of that term: https://htmx.org/essays/how-did-rest-come-to-mean-the-opposite-of-rest/ https://htmx.org/essays/how-did-rest-come-to-mean-the-opposi... https://htmx.org/essays/hateoas/ https://htmx.org/essays/hateoas/ More essays and other silliness here: https://htmx.org/essays/ https://htmx.org/essays/
- bminor13 4y agoQuestion about this part of the hypermedia vs data APIs essay: "This new end point is driven entirely by hypermedia needs, not data model needs. This end point can go away if the hypermedia needs of the application change" Presumably these hypermedia endpoints are all equally accessible - couldn't the removal of one break another application if the latter app decided to depend on a particular hypermedia snippet from the first? If there are multiple teams in an org that own HTMX endpoints, aren't the set of endpoints effectively a sort of interface boundary? Or is there a good way of declaring certain endpoints "private" and ensuring they're only fetched from particular applications? (Maybe separate domains for every app?)
- rglover 4y agoIf you just want to use plain HTML with JavaScript, take a peek at Joystick [1]. 100% plain HTML, CSS, and JavaScript based components (zero attribute hacks or compiler tricks). No external libraries for basic functionality (state, data fetching, url handling—all included or relies on native browser functionality). All a part of one full-stack framework that works out of the box. [1] https://github.com/cheatcode/joystick https://github.com/cheatcode/joystick
- Gys 4y agoI had a quick look at joystick and wonder if you have even read anything related to htmx. Nothing against joystick but it seems more an alternative for frameworks like react and svelte. Those are also npm and jsx based. Htmx is nog ;)
- rglover 4y agoYes, I have. It was one of the things I looked at as part of my initial research before deciding to work on Joystick. What I don't like about is that it's a non-standards based pattern for implementing interactivity in HTML (the same reason I didn't like React, Vue, Svelte, etc). All of these frameworks try to wedge stuff in between the core languages of the web (HTML, CSS, and JavaScript) for the sake of speed/being clever, but ultimately lead developers into a proprietary skills trap. It's all 100% unnecessary and will (arguably, has) lead to massive confusion and messes in the industry. By contrast, Joystick uses plain HTML, plain JavaScript DOM events, and plain CSS to build your UI. It just adds some very thin API abstractions over those features to help you move faster.
- ttfkam 4y agoHonestly, Joystick doesn't seem at all like React, Vue, or Svelte. You have a lot there in terms of email templates, database connections, and other "full stack" items that far exceed the scope of the others. React is certainly a LOT more cognitive overhead than plain old HTML/CSS/JS. Vue, yes, to a lesser extent than React. But honestly, Svelte is closer to "just plain CSS and HTML" as I've even seen in a framework that also allows two-way data binding, which let's face it is a RPITA in vanilla JS. Automatic scoping of CSS to a component is also nice when you aren't trying to set a global style. This by the way is coming from a guy who started writing for the web in 1996, back when document.write() was de rigueur. That said, I honestly do miss the old days of figuring out how to make something on a web page by simply hitting "View Source" and picking out the relevant tags.
- butonic 4y agoIs it possible to send any HTTP verbs, say PROPFIND, SEARCH or REPORT from WebDAV?
- recursivedoubts 4y agonot currently, but I'd be interested in looking at that if those actions are supported!
- Alifatisk 4y agoIs this similar to Alpine.js?
- bnert 4y agoI'd say it's more complementary, from my experience. Alpine serves the purpose of local state and rendering logic for user interaction in a manner similar to a SPA, whereas htmx services integrating w/ your backend service and handling DOM patching for updates/data oriented interactive bits.
- Zamicol 4y ago"The best thing we can do today to JavaScript is to retire it." - Douglas Crockford, creator of JSON
- mirekrusin 4y agoWe already did in favor of TypeScript.
- bogwog 4y agoTypescript is a bandaid. We need improved DOM access for web assembly, followed by a new icon in the URL bar that indicates you're on a "legacy" site if it's using javascript (my vote is for a cute snail emoji)
- mirekrusin 4y agoWe should make more bandaids like this, taking over big chunks of the programming world.
- llanowarelves 4y agoGoogle-affiliated Carbon looks awesome (to fix often-hated C++). What I like is that they have skin the game (sunk cost of millions LOC of C++ to maintain) to make it highly interopable.
- nop_slide 4y agoFunny enough I just watched this talk last night by the creator of HTMX https://www.youtube.com/watch?v=LRrrxQXWdhI https://www.youtube.com/watch?v=LRrrxQXWdhI He mentions that "With HTMX we use a little bit of JavaScript so that we don't have to use any JavaScript."
- casey2 4y agoI don't know any javascript, but is it really that bad of a language that you need new libraries every day and workarounds so that you don't have to write it?
- camdenlock 4y agoYes.
- silent_cal 4y agoYep!
- artificialLimbs 4y agohttps://www.destroyallsoftware.com/talks/wat https://www.destroyallsoftware.com/talks/wat
- benji-york 4y agoThe language itself isn't great, but the tooling it (appears to) necessitate and the fact that the browser isn't a great environment for what many people want to do combine to turn many people off.
- agos 4y agoa lot of people in the last 15 or so years felt strongly that writing javascript was not "real programming", and this facilitated the birth of a thousand solutions to avoid writing it
- cod1r 4y agohttps://news.ycombinator.com/from?site=htmx.org https://news.ycombinator.com/from?site=htmx.org
- t8sr 4y agoI'm confused about what value this adds. The introductory example is certainly not helpful, as it takes an `<a href="/blog">Blog</a>` and turns into 7 lines of markup to accomplish the same thing. (And then it says a bunch of things that are arguably not desirable, like "any element can now trigger requests".) Like: what's the point of using this over HTML5+js? I've spent 15 minutes reading the website and I still don't understand why I should want this, especially if I already know HTML/CSS/JS. All it seems to do is add a SGML DSL into your HTML, so you can be all declarative about `onclick` attributes. I am sure I'm missing something - what is it?
- xmonkee 4y agoConsider the case of calling your backend with a POST call and then updating your app in response. Typically, for a SPA: your backend would return some data, and your frontend would then figure out how to update your html in response to it. For a multi-page-app: your backend will redirect the user to a whole new page with new HTML. This is somewhere in between: Your backend will send just a little bit of HTML and you can update your existing HTML with it. It should feel like coding an MPA, but get the benefits of an SPA.
- t8sr 4y agoYeah, that I understand. I am not a huge fan of sending JSON that's not backwards compatible. Sending HTML is probably a good choice for some applications, but that was already well supported 20 years ago. Why is htmx better than one line of javascript saying `onload = function() { e.innerHTML = response.body` } ?
- mejutoco 4y agoPlease see my answer above, but htmx has some swap attributes where you can declaratively update as many elements of the page as you want. You can grep this id and find all the updates easily.
- crote 4y agoIn practice you don't want to just swap the content 100% of the time. Appending to the current content is quite common too, as is deleting from it. You sometimes need to touch other elements too, or maybe show a progress spinner. Or perhaps push a URL to the navigation history. Htmx provides a batteries-included data-driven experience. It is a means to avoid having to write dozens of slightly different variants of the same 5-10 lines of Javascript.
- beauHD 4y ago> The fastest way to get going with htmx is to load it via a CDN HTMLX is great and all, but loading it from a CDN is insecure and wrought with problems. Namely, the JS file in question could be hijacked and replaced with a malicious version that can steal data. It's unlikely, but still a plausible scenario. Also: the resource could just 404 and not be available due to work-in-progress scenarios on the CDN side. I would much rather host it on my own domain that I control.
- altano 4y agoUsing JS off a CDN is not a security issue if you use Subresource Integrity: https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity https://developer.mozilla.org/en-US/docs/Web/Security/Subres... You can ensure you're always running the version of the script you validated, assuming you even validate the code (which presumably no one does).
- can3p 4y agoIt’s not hard to have it imported from node modules and built with webpack or similar
- _whiteCaps_ 4y agoI haven't done much frontend dev work, but I thought that's what the integrity keyword is for: <script src="https://example.com/example-framework.js" integrity="sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC" crossorigin="anonymous"></script>
- infogulch 4y agoThe Installing section suggests exactly this for users just getting started: https://htmx.org/docs/#installing https://htmx.org/docs/#installing And then it says in the docs right after: > While the CDN approach is extremely simple, you may want to consider not using CDNs in production. > The next easiest way to install htmx is to simply copy it into your project. > Download htmx.min.js from unpkg.com and add it to the appropriate directory in your project and include it where necessary with a <script> tag: Someone else in the thread was asking about webpack. webpack. What has javascript done to people's expectations?
- Xeoncross 4y ago1. One of the most painful thing with SSR forms is passing the data back-and-forth between the server and client when there are validation errors. Sometimes the data is very sensitive and you have to return the form with some values (like SSN) empty and make the user retype that along with with whatever field(s) were the actual issue. I'm also curious about how file uploads would work. 2. REST/GraphQL/gRPC API. Often, if you want to open up your API to internal or external users it's a lot easier if the frontend was already written to deal with protobuf or JSON endpoints. Seems like it would be painful to add an API to an htmlx backend. Is there a good way to address these with htmlx?
- fearthetelomere 4y agoRegarding #1, I've found that Phoenix + LiveView has been helpful for these cases. They have great form validation tools using Changesets and the `phx-change` attribute [1]. You can redact certain fields [2], and even treat certain fields like virtual fields (like password not being stored vs the password hash being stored) [3]. Of course, the (potential) drawback is in using Elixir for both front-end and back-end which may be a tough sell to a client or employer. ----- [1]: https://blog.appsignal.com/2021/09/28/real-time-form-validations-with-phoenix-liveview.html https://blog.appsignal.com/2021/09/28/real-time-form-validat... [2]: https://hexdocs.pm/ecto/Ecto.Schema.html#module-redacting-fields https://hexdocs.pm/ecto/Ecto.Schema.html#module-redacting-fi... [3]: https://elixircasts.io/ecto-virtual-attributes https://elixircasts.io/ecto-virtual-attributes
- christophilus 4y agoWhy can’t you hydrate the form with the SSN? If you’re serving it via TLS, there shouldn’t be any problem. It’s no different sending it up to the client than it is for the client to send it down to you. Unless you’re logging every rendered page for some reason, I guess.
- P5fRxh5kUvp2th 4y agoIt was just an example, replace SSN with password if you'd prefer.
- 4y ago
- harlanji 4y agoHappy to see HTMx mentioned every month or two on here lately. A+, would recommend to anyone especially newbies. Been doing web dev since the Perl / pre-PHP3 / pre-jQuery/Scriptaculous days, and I feel reincarnated into a nicely crafted framework from that time. I've been picking up Python for the past 6 months and adding as little as possible and slowly as possible. About 2 months ago I started building a Twitter client with HTMx + Flask and it's been nice. It now supports multilogins for Twitter and Mastodon, as well as Twitter Archive and RSS/Atom backends. Very similar to programming with PHP back in the day. Minimal JS, just a couple functions to integrate with my little Notes app that's not running HTMx (yet). Not trying to boast, just showing how far one can take it. Using the server as an engine of state with the Facade pattern is something I've already become happy to do, having successfully used it for a pretty delicate use case involving multiple iOS App Store versions and a backend migration without impacting old App versions. I'm a little cautious about offline apps (SPA-domain), but have done a Service Worker demo and have some ideas to mess around with in mind. It's the one possible downside to not using JS (Node) on the backend that I can see: no shared code that can run on the backend and client/edge alike (but a language subset transpiler fills in the gap, eg. for validation/pure/non-mutant logic). Documentation is pretty clear as well, I've been able to go a long way just reading it over and over and trying out features as I think of them.
- deleted 4y ago[deleted]
- scoofy 4y agoHtmx isn’t everything I want it to be, but it lets me program python back end with a mostly python api. I use it for http://golfcourse.wiki http://golfcourse.wiki and I’d recommend it to others who prefer to avoid JS when they can.
- sureglymop 4y agoInteresting! Is it open source?
- scoofy 4y agoNot yet. Eventually, but right now it's just a hobby trying to become a business, and until I get a big enough database to provide a moat, I'm a bit nervous about giving it away for free. I'm not sure if that's the best course of action, but I'm just a guy who's a bit embarrassed to really like to programming in python and playing golf.
- sureglymop 4y agoI completely understand, best of luck with your project! I was looking for an example authentication implementation in htmx that's why it caught my attention.
- scoofy 4y agoI don't use it for that since it's a wiki. I just use a typical sign in page and flask session (which i think is an HMAC hash cookie), but users can obviously edit the wiki without signing in, though with some serious restrictions to discourage vandalism.
- makapuf 4y agoThis pattern is very pleasant and I sure hope browsers would embed as HTML standard a simple version of this (with simple hx-get/post, hx-target and hx-event to start)
- bogwog 4y agoI don't love the idea of implementing common app state logic via attributes. It probably works a lot better than I'm assuming, but it feels hacky to me. Like it can't solve every problem you'd actually encounter when making a complex app, so eventually you'll need to fall back to using javascript, and possibly a framework or three...on top of htmx. But it does seem like this would be fun to play around with using PHP as your backend. No more JSON, or GraphQL, or bloated frameworks, just intermixed code and markup in the same PHP file...just like the good ol' days! For the situations where it does work, this could simplify the architecture of an app significantly. Also, 10/10 meme page. EDIT: are there any large and complex projects using this that are publicly accessible?
- marty331 4y agoI've used HTMX on several projects (Django) and it's truly a great add in. You can basically build a "React" style app with Django. I can't praise it enough.
- alexbezhan 4y agoI'm using htmx for my SaaS web app. It has a lot of spreadsheets. User can filter, sort, highlight with color, etc. It's for PPC managers, they work a lot with spreadsheets. So I'm making a specialized version of that. First two weeks was tough, but after I adapted and found htmx idiomatic recipes to common tasks, it is crazy productive. I can show, if you are curious hit me at twitter @alexblearns. PS. I just believe people have to try it, because it's so much easier to do web apps this way.
- lukeramsden 4y agoSounds like you should be writing some blog posts about writing complex applications with this stuff
- alexbezhan 4y agoI recorded a short video about it here https://youtu.be/JE3zQpEAaxk https://youtu.be/JE3zQpEAaxk
- 4y ago
- can3p 4y agoI like gymzaal and hyperscript - they solve few cases but those cover something like 99% of what a average app needs. My biggest pain point lies with the docs, there are not many of them and it takes time to figure out what’s happening For example, there was no simple way to understand that both libraries are loaded correctly, also it wasn’t immediately obvious where to use htmx and where to start using hyperscript
- nop_slide 4y agoRelevant talk from the creator of HTMX https://www.youtube.com/watch?v=LRrrxQXWdhI https://www.youtube.com/watch?v=LRrrxQXWdhI
- infogulch 4y agoThis is the best of various talks presented by the author imo
- vladstudio 4y agoI feel warm and fuzzy inside every time HTMX is featured on the front page :-) Btw if you are interested in the reasoning of HTMX: https://htmx.org/essays/ https://htmx.org/essays/
- jonesnc 4y agoWe're migrating our apps from Vue.js to HTMX, and it has been a great experience. The size of our codebase has consistently gone down as we move things to HTMX, and it feels like the level of complexity goes down as well. I highly recommend using HTMX.
- hedgehog 4y agoWhat kind of apps? I used Intercooler (sort of a predecessor to HTMX) for a personal project and it worked well but I didn't get a good feel for what it would be like to build more complicated UI.
- megaman821 4y agoI don't think UI is part of HTMX's concerns. It is a library for submitting data and loading HTML fragments. For general UI components, I like https://shoelace.style/ https://shoelace.style/.
- codegeek 4y agoWould you be open to sharing your experience on this a bit more ? We have a JS heavy app with 100s of VueJS components. Could those be transferred to HTMX ?
- StreamBright 4y agoWe are planning to do the same thing. Would you have any write up that you could share?
- x-complexity 4y agoIf possible: Can you say how much of the code reduction is based on not needing to manually handle bespoke request behavior? (errors, transitions, animations, etc.) Also: How much has the backend's responsibility in pre-rendering grown in response to the move to HTMX?
- k__ 4y ago"When a user clicks on this link, issue an HTTP GET request to '/blog' and load the response content into the browser window" Why do you want that? Sounds a bit like the hacky stuff PHP did in the first half of the 00s.
- PaulHoule 4y agoI work on a collection of React applications at work and it is OK but at night I am building a workflow engine that trains a text classification model and automates its activities based on that model. It is almost the kind of web application that I built in 2001 but I find it a lot easier to write today than I did back then thanks to my own maturity and numerous refinements to the web platform. The backend is written in Python and uses aiohttp without any "framework" other than some very basic stuff I write myself. I worked for a company that had built something similar (that one was named "Themis", this one is named "Nemesis") that had parts written in Python, Scala and Typescript and we faced the problem of having to update three codebases whenever we made some change, having to deal with three kinds of "dependency hell", etc. It is all the more acute for an R&D project where adding a new task or model should be a day's work. With very little Javascript I am getting performance close to a desktop application when my server is on localhost, it helps that I am paging out small screenfuls of data. I have to admit that a library like Htmx could be a big help for this kind of application but I've yet to really wrap my head around fitting it into my application.
- christophilus 4y agoI did something similar with Bun recently. I built a little finance / budgeting app (and some bookmarklets) to track, categorize, and visualize my spending. There’s almost no client-side JS. But when I need to sprinkle it in, I just write a function and it’s serialized and sent to the browser automatically by my JSX template layer (built into Bun). It’s quite nice.
- cryptonector 4y agoVery nice, but this: > Now any HTTP verb, not just GET and POST, can be used requires care. I'm assuming HTMX is just a JS library that attaches all these behaviors to HTML. That's fine, as that won't change anything as far as cross-site scripting goes. It's just that if this were coded in the browser, and the responses to these requests made available to the page, then bad things would happen. Also regarding this: > Note that when you are using htmx, on the server side you typically respond with HTML, not JSON. This keeps you firmly within the original web programming model, using Hypertext As The Engine Of Application State without even needing to really understand that concept. it's much easier to write server-side APIs that produce JSON and static HTML + JS that consumes it than it is to generate HTML (and then also JSON for non-browser apps). On the whole I like this a lot.
- dang 4y agoRelated: Moving from React to htmx - https://news.ycombinator.com/item?id=33218439 https://news.ycombinator.com/item?id=33218439 - Oct 2022 (315 comments) An SPA Alternative - https://news.ycombinator.com/item?id=32148253 https://news.ycombinator.com/item?id=32148253 - July 2022 (138 comments) Reimagining front-end web development with htmx and hyperscript - https://news.ycombinator.com/item?id=31949621 https://news.ycombinator.com/item?id=31949621 - July 2022 (207 comments) Building a fullstack app with Flask and Htmx - https://news.ycombinator.com/item?id=30843275 https://news.ycombinator.com/item?id=30843275 - March 2022 (140 comments) The Renaissance of server side rendering with Alpine and HTMX - https://news.ycombinator.com/item?id=30577181 https://news.ycombinator.com/item?id=30577181 - March 2022 (9 comments) How a hypermedia approach can address usability concerns with multi-page apps - https://news.ycombinator.com/item?id=29693571 https://news.ycombinator.com/item?id=29693571 - Dec 2021 (128 comments) Building a simple room-based chat application in Nim (using HTMX) - https://news.ycombinator.com/item?id=29594763 https://news.ycombinator.com/item?id=29594763 - Dec 2021 (28 comments) Django, HTMX and Alpine.js: Modern websites, JavaScript optional - https://news.ycombinator.com/item?id=29319034 https://news.ycombinator.com/item?id=29319034 - Nov 2021 (274 comments) Htmx 1.2.0 Release - https://news.ycombinator.com/item?id=26128229 https://news.ycombinator.com/item?id=26128229 - Feb 2021 (25 comments) Htmx 1.0.0 Release - https://news.ycombinator.com/item?id=25232719 https://news.ycombinator.com/item?id=25232719 - Nov 2020 (58 comments) Htmx – high power tools for HTML - https://news.ycombinator.com/item?id=23330881 https://news.ycombinator.com/item?id=23330881 - May 2020 (166 comments)
- shanebellone 4y agoI'll stick with Python and HTML.
- Xeoncross 4y agoIs there something like this that is a bit lighter than 135KB (source) / 40KB (dist)?
- recursivedoubts 4y agohtmx is 13kb min/ziped, or 15ms over emerging 4G: https://bundlephobia.com/package/htmx.org@1.8.4 https://bundlephobia.com/package/htmx.org@1.8.4
- jstummbillig 4y agoCan anyone with experience in both talk about how stimulus and htmx compare? Or why they don't?
- peteforde 4y agoApples to Oranges You'd be better off comparing https://mrujs.com https://mrujs.com to HTMX Stimulus is a way to attach behaviours to DOM elements. It has no remote concept and no rendering concept. It's freaking awesome, IMO. But it has nothing to do with the problems HTMX wants to solve.
- synergy20 4y agowhile I like htmx it's really for SSR frameworks specifically for django as rails has hotwire and laravel has livewire all do similar things. then you have alpine.js that is more a simple jquery for frontend js work. if you do django, use htmx, I'm not sure how it works for other scenarios. For rich desktop like apps, SPA is still probably the only option.
- mekster 4y agoHow is htmx tied to a specific backend language? How does htmx differ against hotwire and livewire?
- efields 4y agoThis is refreshing, and not unlike what Stimulus is trying to do in the RoR space. This is simpler than Stimulus, IMHO. So much about modern FE dev requires knowing stuff that was intentionally abstracted to purer forms years if not _decades_ ago and easy to pull off in a browser<>server relationship with a little bit of JS for state management or swapping content. The author even uses the phrase "AJAX," which I feel like I haven't seen used in earnest in years. This library is for the OGs. Obviously, trade offs etc etc. If you're starting a new web based project, something that's just submitting forms and showing results, why would you really use anything more complicated than this? It's sorta hilarious that JSX took off; it shows that the declarative nature of HTML was right all along.
- talideon 4y agoHTMX is the perfect example of a project that, like jQuery, exists to be replaced with a W3C standard. And I don't think the people behind it would feel at all bad about that, as it fills a real niche that ought to have been filled a decade ago.
- recursivedoubts 4y ago100% I would love it if htmx was pulled into the HTML standard, that's where it belongs and I would get more sleep :)
- BeFlatXIII 4y agoWe could've been saved from gigabytes of JavaScript if HTML 1.0 specified that tables must be sortable by clicking their headers.
- naasking 4y agoMaybe, but probably not because it wouldn't help with paginated data sets displayed in tables. You don't want to sort only the items you currently see, but across the whole data set most of which is likely not loaded.
- HenriTEL 4y agoHTML imports got deprecated in favor of ES modules, because JS was required anyway to use those imports. I was disappointed at the time as I wish we could make web components without touching JS directly. Now with HTMX the future sounds promising.
- namuol 4y agoWould love to see more opinionated approaches for client side templates/components to enable things like optimistic updates with similar ergonomics.
- foota 4y agoFake logic attributes are my least favorite part of a js framework.
- pvorb 4y agoThis looks very similar to Hotwire. Does anyone have experience in both libraries and give a few hints about pros and cons of both libraries?
- bitterblotter 4y agoI've been working on a HTMX Playground! https://lassebomh.github.io/htmx-sandbox/ https://lassebomh.github.io/htmx-sandbox/ It runs a small mock server inside the browser which is very Django inspired, so it should be very familiar if you have experience with it. The mock server runs using PollyJS and Nunjucks as the templating engine. There is sadly no mobile support or the ability to save yet, but it's still a great place to start tinkering without needing a full setup. Repo: https://github.com/lassebomh/htmx-sandbox https://github.com/lassebomh/htmx-sandbox
- recursivedoubts 4y agovery cool! you should post this in the #showcase channel on the htmx discord! and submit it to the /r/htmx! https://htmx.org/discord https://htmx.org/discord
- bitterblotter 4y agoAbsolutely! I will definitely do that when you can save and share playgrounds :)
- mathgladiator 4y agoI was inspired by Htmx to simply fix HTML, and I believe HTMX is a great way to go if you are using a traditional backend. However, I believe in a better way if you have a better backend. This is what I'm working on as I build a "vertically integrated online board game studio" where I own the infrastructure, the clients, the frameworks, and now gaming runtimes.
- StreamBright 4y agoMy problem with JS is that every framework we tried sucks in different ways. The worst is to handle the kind of silly crap that JS does (wat). The other big part is the every bricking API of pretty much everything. We are lucky if there is no warning about deprecation for a couple of day after updating a library. Minor version changes regularly break the build. The best is when yarn dev works and after building the app and deploying it to prod it breaks. After dealing with these issues for years I am really happy to return HTML from a backend API that uses a language where [1, 2, 12, 3].sort() return what I expect from a sorting function sorting integers. That is all, and that is what htmx gives us. I am not sure if we can replace our UIs that are written in Vue for now but at least it I have a good time porting some of the web things to htmx + Rust from Vue + Python.
- revskill 4y agoModern frontend is easy to get burn out not by the complexities of tooling. It's more about upgrade and backward compatibility. Same story as backend, but backend is likely less broken on that aspect.
- toinbis 4y agoI guess it's important to note that in many cases you'll be willing to pair htmx with either alpine.js (using https://htmx.org/extensions/alpine-morph/ https://htmx.org/extensions/alpine-morph/), or with hyperscript (https://hyperscript.org/ https://hyperscript.org/, developed by same team as htmx). Things that don't require request to server - managed by alpine, things that do require - by htmx. There are situations where both tools can be used, one has to pick.
- getcrunk 4y agoI’ve been looking for alpine and forgot what it was called, have come across it some time ago. I knew I would find it in the comments on this post as it’s kind of like htmx. I didn’t even know the same people made both!
- recursivedoubts 4y ago:) I didn't make alpine, that caleb porzio (a genius) I did make https://hyperscript.org https://hyperscript.org, which is kinda in the same space but very different than pretty much everything else
- pndpo 4y agoAaaannnd we’ve come full circle.
- _HMCB_ 4y agoI love HTMX.
- TrispusAttucks 4y agoThis is genius and beautiful. Burn the frontend js frameworks!
- mattbillenstein 4y agoHas anyone cleanly bolted htmx into Flask or another similar Python framework? I typically use mako for templates and htmx partials or components or whatever you want to call them would seem to cleanly map to mako includes - but I'm not sure how I might connect the render context which is typically collected for the top-level page in a tidy way. Appreciate hearing others thoughts.
- mesarvagya 4y agoFYI: https://htmx.org/server-examples/ https://htmx.org/server-examples/
- mattbillenstein 4y agoThanks, a couple of these look like rendering sub-templates, one actually just loads sub-templates over ajax even on first page render... I'm thinking to have a function in the view that collects the context and renders a sub-template - and then making these functions callable from within a top-level template or from an ajax request... Seems simple enough.
- joshlemer 4y agoI'd like to make a small plug for a really awesome Golang web development starter kit I found recently called pagoda (https://github.com/mikestefanello/pagoda https://github.com/mikestefanello/pagoda). It wires up HTMX, together with Alpine.js and Bulma CSS, onto a really fantastic collection of Go libraries on the back end.
- dools 4y agoMy colleague and I created a library 11 years ago which does this without any markup changes: https://github.com/dgrinton/remote-standalone https://github.com/dgrinton/remote-standalone
- jonotime 4y agoI like HTMX. But I got stuck with the fact that there is no url routing or history. After using things like React and Angluar, I am used to having well defined urls that can get me where I want. Perhaps there is some recommended way to add some other library ontop of htmx, but maybe I'm the only one looking for this?
- aur3s 4y agoHistory? As in, pushing the URL into the browser history when, e.g., navigating a paginated table? HTMX can do that with no issues.
- tmnvix 4y agoMaybe this is what you are looking for? https://htmx.org/docs/#history https://htmx.org/docs/#history
- jonotime 4y agoInteresting, thanks. I stand corrected on the history part. But routing is still left to the user (its even explicitly mentioned in the doc you linked to. For example if a user clicks a link in their email to /movies/2001, it does not know to show the movies frame with the 2001 content. We have to implement some kind of url parsing to determine what divs need updating and then update those on first page load.
- deleted 4y ago[deleted]
- firedev 4y agoDid anyone use it with Rails and Hotwire?
- dec0dedab0de 4y agoI was going to say this reminds me of intercooler.js, but it looks like htmx is a sequel of sorts. Very cool, I used intercooler for some stuff a while ago and I loved it, I'll have to check this out.
- hakanderyal 4y agoWhile I understand the appeal, attribute based frameworks always felt hacky for me. OTOH React immediately clicked, as it is just javascript. I've tried it both back in the Angular 1.0 days, but React came ahead both in the composability and maintainability departments.
- salkadam 4y agoHow do you implement a rich table or pivot-table with decent amount of data and refreshes from backend using HTMX. Any examples?
- mring33621 4y agoI have been trying to learn some modern-ish web development and had good luck with HTMX for a little toy web app that allows you to post a document and a set of search terms and then displays the search results on the same page, avoiding a full refresh. For anyone curious, I used Quarkus & Qute templates for the backend and Bulma for CSS.
- andrewfromx 4y agoslightly off topic but I've been having the best time getting back into rails version 7. (I left the rails world back in 2014) This tutorial https://www.hotrails.dev/turbo-rails/css-ruby-on-rails https://www.hotrails.dev/turbo-rails/css-ruby-on-rails makes clean views with auto magical css that just works. It is amazing.
- Alifatisk 4y agoBeen looking for an excuse to get started with Rails 7 & hotwire.
- tsaixingwei 4y agoI still remember a time when recursivedoubts posted about intercooler.js which is the predecessor to htmx, and almost every comment was dismissive and a varition of “what’s the point of this?”. It seems now the majority of commenters are positive about htmx now and I feel happy for recursivedoubts. Most web applications today would benefit from using htmx more than JavaScript-heavy frameworks with the exception of applications like Figma and the like of it.
- recursivedoubts 4y ago:) it has been a long slog, but I'm glad that it's getting a more positive reception now, and I really appreciate your well wishes
- drudru 4y agoFunny - top stories right now are Sveltekit 1.0 and htmx. At their heart, each is fundamentally going in a different direction. I wonder how many people are upvoting both.
- doodlesdev 4y agoThey serve different purposes though. SvelteKit is a great full stack framework using Svelte for the frontend, which is great for SPAs, PWAs, and any other kind of WAs you might want. HTMX serves essentially as an extension to HTML itself, allowing you to make web PAGES which are interactive. Not talking about Alpine or Hyperscript though since those two start mudding the water a bit.
- andreygrehov 4y agoOh. My. God. This is amazing. I absolutely hate all the complexity of the modern front-end development. I hate it so much that I use `<meta http-equiv="refresh" content="3">` for status pages waiting for the result from the server. Just by looking at htmx, this is a breath of fresh air. Love the simplicity and how they managed to abstract all the complexity away. IMHO, this should become the HTML standard.
- reverseblade2 4y agoCareful, it doesn't work inside shadow dom, nor hyperscript.
- sandGorgon 4y agowhat does this mean ? i have been recommended hyperscript over alpinejs several times.
- reverseblade2 4y agoHTMX can't find dom nodes inside Shadow DOM and hyperscript can't execute scripts injected inside a shadow dom. So no web components.
- sandGorgon 4y agoIs anyone here working with Java and HTMX ? we have faced a lot of resistance in doing this. Basically because java already has versions of server side rendered frameworks - specifically JSP & Thymeleaf. So while, the value proposition of HTMX for the larger nodejs world (or anyone using React) is "back to Server Side Rendering". I'm kind of struggling to build a value prop on the JSP/Thymeleaf side which is already popular. So is HTMX a "better JSP" ?
- MilStdJunkie 4y agoGetting some MacroMedia ColdFusion flashbacks! But not in a bad way.
- sgt 4y agoI showed this to a few frontend developer friends and they actually got a bit defensive and dismissive. What are they going to do if they can't build SPA monstrosities? I know, it's a ridiculous thought, right? There's always going to be challenging work to do, but some people are entrenched in VueJS/React/Angular, and relish spending 10x the time building CRUD apps.
- transfire 4y agoI think the general concept is spot on. Some of these features are sorely overdue for HTML. However, looking at some of the more complex features it starts to feel like they are not all suited to HTML, but seem more fitting to CSS. Perhaps, even, we need something akin to CSS but dedicated to coordinating events and requests? I’m not sure. I get the feeling Htmx is a big step in right direction, but I don’t think we’re quite “there” yet. I also think JSON has its place (b/c it’s pure data), and wouldn’t be too quick to completely chuck it out in favor of an all HTML replacement (data with markup).
- kaeshiwaza 4y agoI'm using htmx in production since one year. From game (scrabble game with board refresh, chat and so on -with sse extension-) and cms to professional crud apps. With Go + stdlib template. Now looking at PWA, it seems to fit very well. What i like with htmx is that it's very easy to upgrade step by step a legacy SSR app. And the opposite. I mean it will be easy to switch to an other ajax lib or if w3c add similar functionalities in 10 years. To use htmx is mostly to replace whole pages with fragments, that's interesting even when we don't use htmx, sort of server side web components. In other world, just try ! I'm fighting myself to don't give back examples to the community but i'm so exited to upgrade my very old legacy apps !
- replwoacause 4y agoFrom the page: > It's worth mentioning that, if you prefer, you can use the data- prefix when using htmx Why is this worth mentioning and what difference does adding the prefix make?
- mekster 4y agoTo avoid your editor from puking with bunch of invalid HTML markups?
- nsonha 4y agoIt's take a special type of arrogance to just deny the reason why front end development has been moving heavily toward code (javascript) instead of mark up. This same group of people recently has made a lot of noise about freaking form methods and that sort of thing, sorry we knew about them 20 years ago, didn't scale.
- knighthack 4y agoHTMX is hands down one of the greatest tools of the past few years. Very happy with it and Django.
- err4nt 4y agoThis is another project that teaches you to write non-standard, invalid code, with the hopes that a tool will come along and transform it into valid, standard code later. And there's no need, because there are multiple ways in HTML they could already express this without violating HTML. Here are 2 ways that work, and then the way they've done it which is in violation: Possible method 1: Data attributes. Any time you as an author want to add additional data to an element, you are free to invent any custom attribute names you want, so long as they begin with "data-". Possible method 2: Custom elements. Any time you as an author want to add a custom element to HTML, you are free to invent any tag name so long as it follows a simple naming criteria (essentially [a-z]+-[a-z]+) and if you invent any custom element, you are allowed to define whatever attributes on it you like. Invalid method chosen: To pollute standard elements with invalid attribute names in violation of the HTML standard.
- mrzool 4y ago> Possible method 1: Data attributes. Any time you as an author want to add additional data to an element, you are free to invent any custom attribute names you want, so long as they begin with "data-". From the linked docs: > It's worth mentioning that, if you prefer, you can use the data- prefix when using htmx: <a data-hx-post="/click">Click Me!</a>
- uranusjr 4y agoGiven the documentation actually list the data-* syntax as an alternative (and pretty much near the top), I’m assuming they are aware of the problem, but still prefer the non-standard-compliant attributes.
- smp4063 4y agoHtmx in a Nutshell https://news.ycombinator.com/item?id=33987578 https://news.ycombinator.com/item?id=33987578
- smp4063 4y ago[dead]