News for hackers. Stuff that matters.
Re:The Future (and the Past) of the Web Is Server Side Rende... by silver-arrow on Friday February 03, 2023 @03:00PM (#34646946)
Much more prefer the htmx way of SSR parts of the page dynamically. Also, totally server-side agnostic, so we can use what we prefer. Clojure in our case.

https://htmx.org/

Re:The Future (and the Past) of the Web Is Server Side Rende... by greg_tb on Friday February 03, 2023 @03:29PM (#34647286)
Completely agree.

For me the biggest advantage is eliminating the need to learn, debug, and maintain components on an additional frontend framework (Angular/React/Vue).

I just built a rough toy project [0] that was my first time with FastAPI and HTMX and it was fun and fast.

[0] https://www.truebuy.com/ (like rotten tomatoes for product reviews but just for TVs right now)

Re:The Future (and the Past) of the Web Is Server Side Rende... by 0xdeadbeefbabe on Friday February 03, 2023 @04:13PM (#34647785)
It's consumer reports but faster :)
Re:The Future (and the Past) of the Web Is Server Side Rende... by greg_tb on Friday February 03, 2023 @05:10PM (#34648452)
Thanks. Speed and quality content is what I've been focused on. I was tired of Google search spam and Amazon review rot so built this to try expose good/trusted/authentic content.
Re:The Future (and the Past) of the Web Is Server Side Rende... by recursive on Friday February 03, 2023 @05:14PM (#34648514)
I love the concept, but for my case, I'd need more granular filters. In particular, I only buy TVs that have analog audio outputs so I can hook them up to any speakers. That's a minority of TVs these days, but there are still a few around. Finding the good ones would be useful to me.
Re:The Future (and the Past) of the Web Is Server Side Rende... by no_wizard on Friday February 03, 2023 @07:08PM (#34649689)
I assume that converters have negative side effects?
Re:The Future (and the Past) of the Web Is Server Side Rende... by recursive on Friday February 03, 2023 @10:33PM (#34651154)
I'm unaware of their existence. I'm guessing they're big and expensive. Or maybe hard to get?
Re:The Future (and the Past) of the Web Is Server Side Rende... by fshr on Friday February 03, 2023 @11:13PM (#34651441)
What kind of outputs? Fiber to analog is about $15 and the size of two hockey pucks stacked.
Re:The Future (and the Past) of the Web Is Server Side Rende... by recursive on Saturday February 04, 2023 @12:21AM (#34651794)
Huh. Ok. I just didn't know that was a thing. Ok, I guess I don't need analog outputs then. Still nice to have though. Better zero pucks than two.
Re:The Future (and the Past) of the Web Is Server Side Rende... by pas on Sunday February 05, 2023 @08:24PM (#34672030)
Hifi geeks don't trust the DAC to something inside the TV, and ... they are not wrong. Plus you can reuse the DAC even if you change the screen.
Re:The Future (and the Past) of the Web Is Server Side Rende... by recursive on Sunday February 05, 2023 @11:59PM (#34673534)
I'm not an audiophile. I just want something better than what the screen does, and I don't want to buy a soundbar or get into HDMI. And sometimes use headphones.

But still, I'm pretty sure, one day I'm going to get one of these optical -> analog boxes.

Re:The Future (and the Past) of the Web Is Server Side Rende... by robertoandred on Friday February 03, 2023 @04:14PM (#34647790)
So any change in the UI means sending a request to the server, waiting for it to render, and waiting for that response with the new markup?
Re:The Future (and the Past) of the Web Is Server Side Rende... by silver-arrow on Friday February 03, 2023 @04:26PM (#34647925)
Yes indeed! The core aspect, however, is that your server is returning fragments of html that htmx places in the DOM extremely quickly. They have pretty good examples on their site illustrating some "modern" UI patterns.

As an example, you may have an HTML table on your page that you want to insert a new row for some reason on let's say a button click. You place some attributes that htmx understands on your button that will call for the TR HTML chunk from the server. You can imagine replacing all the rows for a paging click etc.

Again check out the example for cool stuff.

Re:The Future (and the Past) of the Web Is Server Side Rende... by robertoandred on Friday February 03, 2023 @05:01PM (#34648338)
Sounds pretty slow. At least a second before the UI responds to any action?
Re:The Future (and the Past) of the Web Is Server Side Rende... by BizarreByte on Friday February 03, 2023 @05:33PM (#34648734)
It’s much faster than that in practice, but of course it comes down to how well your backend is written. I’ve been using HTMX lately and I can blink and miss the UI updates.

I wish I had numbers, but in my experience it’s far better than you’d expect. Basically take the length of a REST call you’d have to make anyway and add a few milliseconds for the rendering.

Re:The Future (and the Past) of the Web Is Server Side Rende... by throwawaymaths on Friday February 03, 2023 @08:13PM (#34650212)
It seems such a waste... You're chucking all that cryptography (ssl, encrypted cookies) away only to be redone every. single. Dom change
Re:The Future (and the Past) of the Web Is Server Side Rende... by movedx on Friday February 03, 2023 @09:09PM (#34650642)
Huh? How does HTMLx "chuck" away SSL (you meant TLS, right? I hope you're not using SSL) and encrypted cookies?

How about you try it and see?

Re:The Future (and the Past) of the Web Is Server Side Rende... by devin on Friday February 03, 2023 @09:40PM (#34650819)
It’s fine to use SSL interchangeably with TLS IMO. It’s still called OpenSSL.
Re:The Future (and the Past) of the Web Is Server Side Rende... by movedx on Saturday February 04, 2023 @12:26AM (#34651809)
I suppose, but it's not really that big of an effort to just use the correct term for the correct version of the technology.
Re:The Future (and the Past) of the Web Is Server Side Rende... by throwawaymaths on Saturday February 04, 2023 @01:22AM (#34652087)
The certs are generally called SSL certs, not tls certs, too.
Re:The Future (and the Past) of the Web Is Server Side Rende... by movedx on Monday February 06, 2023 @09:30PM (#34687856)
> AWS Certificate Manager - Provision and manage SSL/TLS certificates with AWS services and connected resources

Both, I guess.

Re:The Future (and the Past) of the Web Is Server Side Rende... by throwawaymaths on Saturday February 04, 2023 @01:20AM (#34652075)
By chuck away I mean all those processor cycles to perform cryptographic verification... And then throw away the result because you have to do it on the next connect anyways

And I have written a library that does the full SSL handshake/upgrade cycle off of tcp sockets, and managed my own private CA, so I'm not a total idiot.

Re:The Future (and the Past) of the Web Is Server Side Rende... by dan1234 on Saturday February 04, 2023 @02:54AM (#34652599)
Isn’t that mitigated with TLS session resumption and TLS 1.3’s 0-RTT?
Re:The Future (and the Past) of the Web Is Server Side Rende... by kaba0 on Saturday February 04, 2023 @03:08AM (#34652673)
How is that different than all the other CSR SPAs that do a REST call on every button press as well? They do almost the same amount of work, and will also “throw away” the results.
Re:The Future (and the Past) of the Web Is Server Side Rende... by throwawaymaths on Saturday February 04, 2023 @07:01AM (#34653817)
It's not, but there are server side options (topic of op) where it's a websocket. I believe HTMx supports ws too, but gp was only talking about RESTful round-trips
Re:The Future (and the Past) of the Web Is Server Side Rende... by amelius on Friday February 03, 2023 @08:25PM (#34650315)
> but of course it comes down to how well your backend is written

Also the latency of your connection matters.

Re:The Future (and the Past) of the Web Is Server Side Rende... by BizarreByte on Friday February 03, 2023 @09:32PM (#34650773)
I thought frontend devs stopped caring about bad connections years ago? ;)

HTMX is fine with showing loading icons are the like if needed, but yah, connection latency is going to have an effect.

Re:The Future (and the Past) of the Web Is Server Side Rende... by silver-arrow on Friday February 03, 2023 @05:34PM (#34648746)
You for sure wouldn't want to build a spreadsheet type app with htmx because of that aspect. Many other types of web apps can benefit from the simplification of the architecture, however. And like my paging example, many times you need to go to the server anyway. But sure, like anything, I wouldn't use htmx for every situation.
Re:The Future (and the Past) of the Web Is Server Side Rende... by silver-arrow on Friday February 03, 2023 @05:36PM (#34648778)
True BizarreByte. I love how htmx let's you easily add animation indicators on actions, because many times it's too fast due to the small chunks coming back and getting placed so quickly in the DOM
Re:The Future (and the Past) of the Web Is Server Side Rende... by berkle4455 on Friday February 03, 2023 @08:53PM (#34650524)
What sort of slow backends do you work with? My PHP htmx application responds in ~30ms including network transmit. Even if you’re across an ocean it’s maybe 300ms.
Re:The Future (and the Past) of the Web Is Server Side Rende... by b4je7d7wb on Friday February 03, 2023 @10:26PM (#34651103)
300ms feedback on user action is unacceptable. But I read another comment saying there can be loading indicators so in that case its fine.
Re:The Future (and the Past) of the Web Is Server Side Rende... by mixmastamyk on Friday February 03, 2023 @10:19PM (#34651068)
Same as a javascript round trip. Can still make local-only changes if you'd like.
Re:The Future (and the Past) of the Web Is Server Side Rende... by dmitrygr on Friday February 03, 2023 @06:23PM (#34649276)
How well does their example work over satellite internet with 1.2sec latency? How about my cell connection when T-mobile throttles me to 64Kbps for going over my data allowance? How about my sister's cell connection, as she is on an MVNO and deprioritized sometimes to 128Kbps, sometimes to 6Mbps, and sometimes it varies within a minute between those two?

FFS, people, learn to write proper software that does everything locally!

Re:The Future (and the Past) of the Web Is Server Side Rende... by simonw on Friday February 03, 2023 @07:13PM (#34649733)
All of the environments you describe there sound to me like they would benefit from web apps that become responsive after an initial page load of less than 100KB, followed by ~10KB round trips to the server to fetch additional data.

As opposed to the >2MB initial page loads that have become so common with heavy React SPAs in exchange for the theoretical benefits of avoiding more page loads for further interactions.

Re:The Future (and the Past) of the Web Is Server Side Rende... by dmitrygr on Friday February 03, 2023 @07:36PM (#34649942)
They benefit from a .exe (or a .tar.gz or a .apk) downloaded when convenient and run locally
Re:The Future (and the Past) of the Web Is Server Side Rende... by camdenreslink on Friday February 03, 2023 @10:08PM (#34651003)
Any app with dynamic data would still need to make some sort of HTTP request before rendering some view with that new data. I don’t really get your point.
Re:The Future (and the Past) of the Web Is Server Side Rende... by hem777 on Friday February 03, 2023 @11:15PM (#34651453)
If the data is also local, which it can be and in many cases should be, there’s no network request round trip.
Re:The Future (and the Past) of the Web Is Server Side Rende... by flangola7 on Saturday February 04, 2023 @12:04AM (#34651713)
My mentor always taught "Program as if it has to run on the far side of Mars."

Software that doesn't need the internet for its function shouldn't connect to the internet. Software that does need the internet should be able to operate under adverse network conditions.

The Voyager probes are 160 AU away, far past Pluto, with a roundtrip latency of 37 hours. The radio transmitter onboard is only about 10x more powerful than a cell phone. The hardware has been in the cold vacuum and hard radiation of space for four and half decades. In spite of this, NASA maintains active two-way communication with it today, and continues to receive scientific telemety data of the outer solar system.

I don't expect web devs to design for deep space, but the core functionality of a website should still work for a rural user with a spotty satellite uplink. Don't do go loading JavaScript or other resource calls until the basics are received. I still remember the days of Facebook being fully functional on a 2G cellular connection, using little or nothing more than static HTML and CSS (and that was before the magic tricks HTML5 can do).

Re:The Future (and the Past) of the Web Is Server Side Rende... by kaba0 on Saturday February 04, 2023 @03:20AM (#34652721)
And what kind of apps are you using? You think Amazon and whatever else doesn’t also start a rest call on basically every action, many of which are “blocking” the UX?
Re:The Future (and the Past) of the Web Is Server Side Rende... by dsego on Friday February 03, 2023 @04:30PM (#34647973)
I built a tiny deno+htmx experiment, you can check it out at https://ssr-playground.deno.dev, it's all server-side rendered html with htmx attributes sprinkled around.
Re:The Future (and the Past) of the Web Is Server Side Rende... by the_gastropod on Friday February 03, 2023 @04:36PM (#34648034)
Versus the overwhelmingly common SPA counterexample where any change in the UI means sending a request to the server, waiting for it return your json response, parsing that json response, building html out of that json response, and updating the dom.
Re:The Future (and the Past) of the Web Is Server Side Rende... by robertoandred on Friday February 03, 2023 @05:05PM (#34648391)
You don't need to wait for a response if you're sending data, or reorganizing data, or doing something that doesn't rely on data.
Re:The Future (and the Past) of the Web Is Server Side Rende... by the_gastropod on Friday February 03, 2023 @05:08PM (#34648432)
Yep. DOM manipulation can be done to server-rendered views to do that kind of thing, just fine. No SPA js framework required.
Re:The Future (and the Past) of the Web Is Server Side Rende... by robertoandred on Friday February 03, 2023 @05:30PM (#34648709)
So now you've got two templates? How do you keep modifications in sync?
Re:The Future (and the Past) of the Web Is Server Side Rende... by ColonelPhantom on Friday February 03, 2023 @06:10PM (#34649153)
Personally I would use htmx and roundtrips for all sorts of modification including data (such as reorganizing two rows in a table). But you'd also do that in an SPA, right? How do you prevent desyncs there? Also for e.g. sorting you'd need a server roundtrip anyway in the (likely) case where you use something like pagination or lazy loading.

For sending data, you would just have a reply that instructs HTMX to display a success message. On an SPA you'd have the same. With both, you can interact with the page while the data is being sent.

Of course, sometimes you want purely 'cosmetic' actions, such as an "add row" button that pops open some data entry fields. For something like that you should not use htmx itself, but instead basic vanilla JS or a simple library such as https://alpinejs.dev/ which complements htmx nicely for client-side stuff.

Re:The Future (and the Past) of the Web Is Server Side Rende... by robertoandred on Friday February 03, 2023 @07:09PM (#34649695)
I mean modifications to the template itself. Design changes, copy changes, etc
Re:The Future (and the Past) of the Web Is Server Side Rende... by acdha on Friday February 03, 2023 @08:31PM (#34650361)
I go with the core idea of progressive enhancement: your front end code can improve what the server sent it rather than completely replacing it - if your style changes don’t break the semantic meaning, you don’t need to change any of your front end code.

What I typically do is render the first bit of data on the server and have the client JS use that as a <template> for changes or new records. That ensures that anything done on the client always matches without you needing to code cosmetics in multiple places but also means your pages load seconds faster than a SPA because the first view is ready to go. When the user saves the entry, you can swap what you generated with the server response a few milliseconds later.

Re:The Future (and the Past) of the Web Is Server Side Rende... by mehphp on Friday February 03, 2023 @04:52PM (#34648236)
Yes, this is how Elixir Phoenix works. The caveat is that only returns exactly what needs to be changed, so it's a small diff.

It's not suitable to everything, but it works really well. I'm not advocating switching to it right now, but it's looking very promising.

Re:The Future (and the Past) of the Web Is Server Side Rende... by mal-2 on Friday February 03, 2023 @10:00PM (#34650961)
htmx glosses over the difficult part, which would be keeping track of the relationship between all these hx-post and hx-target attributes, when they're all just strings in markup. That glossing over is why you don't see any well-established backend libraries on the server integrations page. (https://htmx.org/server-examples/)

Elixir solves this in a much smarter way, because the bindings to reactive values can be validated at compile time, inside the HEEx templates. It's all located together, but you still get the diff passing behavior. (https://hexdocs.pm/phoenix_live_view/assigns-eex.html)

Re:The Future (and the Past) of the Web Is Server Side Rende... by wibblewobble124 on Sunday February 05, 2023 @03:51AM (#34663140)
It’s not a difficult part if you already have a powerful web framework. We’re using Htmx with Servant which has type-safe URLs built in. For the targets, automatic name generation is fine.

I prefer the unopinionated, language agnostic simplicity of htmx, just like HTML, over more tightly bound language specific frameworks. It provides a vocabulary that will translate across backend languages and probably endure over competitor frameworks.

Re:The Future (and the Past) of the Web Is Server Side Rende... by satyrnein on Friday February 03, 2023 @05:10PM (#34648464)
Can the same server side code render that fragment, regardless of whether it's part of the initial page load or a subsequent update? You need an additional route for the Ajax call, right? Just curious how this gets structured.
Re:The Future (and the Past) of the Web Is Server Side Rende... by silver-arrow on Friday February 03, 2023 @05:25PM (#34648657)
Yes it can. Right, your server-side routing would have those routes set-up. Naming them can get interesting :)
Re:The Future (and the Past) of the Web Is Server Side Rende... by codingkoi on Friday February 03, 2023 @07:21PM (#34649805)
I haven’t used it recently but I believe it sets a header on the request when it comes from HTMX so you can change whether you send the whole page or just the fragment back.

You can also just send the whole page and use other features to select just the part that you want to update (obviously that has a cost of sending the whole page though).

Re:The Future (and the Past) of the Web Is Server Side Rende... by jhot on Tuesday February 07, 2023 @08:19AM (#34692340)
Most template engines have some form of inheritance making it easy to render just the fragment or include it in a full page based on route.
Re:The Future (and the Past) of the Web Is Server Side Rende... by BizarreByte on Friday February 03, 2023 @05:42PM (#34648839)
HTMX has to be my favourite thing web related. I never really got React and always found it a bear to setup and use, but HTMX and server ride rendering? Easy and extremely productive for a non-frontend guy like me.

I really hope it or something like it becomes popular long term.

Re:The Future (and the Past) of the Web Is Server Side Rende... by duncan-donuts on Friday February 03, 2023 @08:26PM (#34650324)
I just started using htmx in a new personal project. I’m pretty excited to see how it goes. I’m doing a sort of back to basics stack with PHP, simple classless css lib and htmx. So far it’s been a refreshing experience
Re:The Future (and the Past) of the Web Is Server Side Rende... by cutler on Friday February 03, 2023 @08:55PM (#34650543)
"classless css lib" ??
Re:The Future (and the Past) of the Web Is Server Side Rende... by uneekname on Friday February 03, 2023 @09:26PM (#34650739)
Not op but classless CSS frameworks are awesome. The idea is to keep it simple and use the appropriate HTML tags where there were generally meant to go, and the framework will theme the page to improve usability and add flair. I've developed some great little sites with no classes at all!

Obviously this approach has its limits, but it works well for proof-of-concept sites or sites that don't need to be very complex or dynamic. Just a sensible font size, nicer looking form elements, etc.

Here is a list of classless CSS frameworks: https://github.com/dbohdan/classless-css

Re:The Future (and the Past) of the Web Is Server Side Rende... by 1123581321 on Friday February 03, 2023 @09:28PM (#34650749)
It's a CSS stylesheet you include in every page/view. You don't add any classes to your HTML and rely on the defaults of that stylesheet to style the semantic markup. If those defaults are good for your project, and you have some command of HTML elements beyond using divs and spans for everything, it saves a lot of time.
Re:The Future (and the Past) of the Web Is Server Side Rende... by mmcnl on Saturday February 04, 2023 @11:43AM (#34655751)
htmx only seems to make sense if you're coming from backend frameworks and you want to add some sprinkles of interactivity.