4

Ask HN: What companies are embracing “HTML over the wire”?

 1 year ago
source link: https://news.ycombinator.com/item?id=34744348
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Ask HN: What companies are embracing “HTML over the wire”?

Ask HN: What companies are embracing “HTML over the wire”?
58 points by sodapopcan 1 hour ago | hide | past | favorite | 63 comments
I'm a web developer who has been in the market for a new job for a while now. As someone who has never enjoyed working with frontend JS frameworks (yes, I sucked it up and learned them and have worked with them professionally) I'm wondering who all the companies are who have embraced the semi-recent "HTML over the wire" movement (Can you imagine... using hyper text transfer protocol for transferring hyper text? Seems nuts, I know). It's a massive slog shifting through endless React/Vue/etc-focused jobs out there. Even if you use React in small areas where it pulls its weight but generally try and stick to simplicity of sending plain ol' HTML, I'd love to know who you are. Even if you aren't hiring, it's nice knowing you're out there fighting the good fight :)
You don't even need a fancy "send html fragments over the wire" approach to create a better user and developer experience.

Just sending full pages, server side rendered, like Hacker News and Wikipedia do is fine:

Going from the HN homepage to this topic we are on:

    36 KB in 5 requests.
Going from the Wikipedia Homepage to an article:
    824 KB in 25 requests
Going from the AirBnB homepage to an apartment listing:
    11.4 MB in 265 requests.
Going from the Reddit homepage to a Reddit thread:
    3.74 MB in 40 requests
In comparison to AirBnB and Reddit, HN and Wikipedia feel blazingly fast. And I am sure the developer experience is an order of magnitude nicer as well.
s.gif
Is that AirBnB stat including “content” stuff like images or embedded maps? It’s still worth critiquing the bandwidth spent on that stuff, of course, but it wouldn’t really be fair to include it here when the discussion is about the architecture of page transitions.
s.gif
Page transitions are much faster for me on Wikipedia than on AirBnB.

Whatever I click on AirBnB, I get a white screen, then some placeholders, then the placeholders one after the other get replaced by the actual content.

Whatever I click on Wikipedia - its just there instantly.

s.gif
IF you want the page to be interactive without refreshes though, you gotta do something. Unless you are advocating a completely pre-ajax web.

https://en.wikipedia.org/wiki/Ajax_(programming)

s.gif
A bit of Ajax here and there is fine.

Look at how HN handles it when you upvote/unvote a comment.

Look at how old.reddit.com handles it when you click "load more comments" in a long thread.

s.gif
isnt ajax fancy sending html over the wire? or is it just the non fancy way?
s.gif
AJAX stands for Asynchronous JavaScript And XML--it was originally designed for asynchronously manipulating XML data using JavaScript because at the time, the future was XML. The act of using JavaScript to send requests is still sometimes referred to as AJAX, despite usually not dealing with XML in any way. The most common use for sending asynchronous requests is making API calls, which today generally return JSON, but you could use AJAX to load HTML and dynamically add it to the page.
s.gif
old.reddit feels fast, which is why I use the Old Reddit Redirect extension.
s.gif
Yes, I also use the old Reddit.

What's funny is that the old Reddit makes use of dynamic loading of content here and there the right way. The "load more comments" of the old Reddit is nice and fast. While the "continue this thread" of the new Reddit is annoying and slow.

s.gif
Indeed it is; the UX/UI is also better compared to the low density of information with the new design.
People have gotten way too religious over SPAs, SSR, etc.

Should you use X? Maybe it depends. I have been burned by using SSR when the complexity of the app increased and suddenly doing SSR was getting in the way and now I was uncomfortably mixing JS with server rendered pages and struggling to maintain state. I've also been on the other side, using React and creating more complexity than was needed.

The point is: don't be dogmatic. Get requirements, extrapolate what could happen in the future, use first principles, ask yourself if your decisions are for your own personal reasons or have significant positive user impact.

Engineers who rush to use one technology over the other without doing their homework are just doing bad engineering. It has nothing to do with "fighting the good fight".

old man alert Back in my day, we wrote ASP.NET that was all server-side-rendered HTML. Once in a while we got REAL FANCY and used JQuery to make PARTIAL HTML requests and update only FRAGMENTS of the page. Hooboy I knew that fashion was cyclical but not tech!
s.gif
I wonder if people nowadays know that Ajax (aka. partial HTML requests to update fragments of the page) was a huge leap.

Gmail is one of the first to have adopted this paradigm.

s.gif
Back in the days of MySpace, we were working for a client in UK Sports betting (Littlewoods Pools) - and we managed to persuade MySpace to let us have a script tag on the page, pointing to a JS file we controlled.

The script injected jQuery, then we replaced the page with HTML fragments. We had an Adobe Air installer, a Flash game and even had an RSS feed.

Funnily enough today we're mostly working towards using ESI - which reminds me of mod_include back in the day.

s.gif
Webforms has an UpdatePanel control sending partial HTML (and even additional JavaScript) to web pages.
Is “HTML over the wire” a new buzzword for SSR or is there a difference I'm missing?
s.gif
It is rendered server side, but typically the server keeps track of only what needs to change and sends as small as possible an update to dynamically update the DOM. You end up with a user experience that feels close to an SPA, but a dev experience that feels close to traditional SSR.
s.gif
Having only worked at SPA places, it's hard for me to imagine not having tools like Storybook, Chromatic, and Mocked Service Workers. Building the UI in isolation means with mocked API responses means I can, in parallel, validate 1000's of use cases with pixel-level precision. The backend teams can keep their focus on scalable, performant APIs. The frontend teams can focus on accessibility, consistency, etc. I've found a secret sauce that works very well in my organization, and I'd be curious to know what the equivalent would look like for SSR apps. But I can't overstate of much of a boon it's been to develop the client in isolation. Nearly all my bug reports go straight to the backend teams. It's bliss.
s.gif
Yeah, I hear the HTML-only case more from people who were full-stack or backend. Giving up the tooling around SPAs would be hard. I'm not sure what the equivalent is - is there any frontend-specific advice for backend devs that amounts to "wouldn't it be cool if you gave up all your developer tooling?"
s.gif
Tech like LiveView (Phoenix) and LiveWire (Laravel) are great examples of this.
s.gif
Also Blazer Server (C#) and the upcoming Blazor United slated for .NET 8
s.gif
I've been working on one of those frameworks, although the dev experience feels more like a SPA in this one. https://github.com/mayu-live/framework
s.gif
Partly, but it especially means things like Phoenix LiveView[0] or htmx [1]. With these you can create SPA like experiences by sending partial html updates from the server and applying them by some light JS to the UI (which you don't have to write yourself).

[0] https://hexdocs.pm/phoenix_live_view/Phoenix.LiveView.html [1] https://htmx.org/

s.gif
The first time I saw the concept codified in a library was in a jquery function that allowed you to replace a part of the DOM. Either the method signature or the documentation pointed you to using it in pairing with AJAX requests.

The first webapp framework I saw it in was Rails (turbolinks). I came to Rails late and didn't stay long so I was never clear how old or how broadly used that feature was. Mostly what I got from Rails was being more comfortable writing NodeJS code, which stole shamelessly from Rails.

s.gif
I think it's HTMX etc, so yes SSR. That was how I started building web apps in my first job as a dev, crazy how the loop of front-end technologies is only like 10 years.
s.gif
I think it's referring to partial server-side renders. SSR is usually used to refer to statically rendering pages, while the "new" thing is to dynamically update pages with chunks of SSR-created HTML.
s.gif
Others already answered but that's why I bothered making that little quip about HTTP. It's kind of a ridiculous name but also funny and appropriate since it's trying to state that it's a return to form. My brother who is just started working with web tech recently didn't even realize that it was possible to send HTML over HTTP, lol.
s.gif
Maybe we need to invent some sort of server-side MVC framework? lol
My last gig used Rails' Hotwire, and my new gig is using Phoenix Liveview.

Thankfully people are waking up and seeing that JS is most appropriate as a "last resort" technology.

We are using Django+HTMX for internal applications.

Some random tips:

- Write a "Django context processor" to inspect requests for "Hx-Request" header, and set a "base_template" variable accordingly. This means that any template that {% extends base_template %} will react to being a full page or just a fragment and you don't even have to think about that in your view logic.

- You can get reactive JS elements (for example, a d3.js viz that updates when new data comes in) in a few lines of inline JS by using MutationObserver, and "abusing" HTMX by using views that return JSON targeting a <script> element (`json_script` templatetag can also be used here). In summary, you tell your fancy JS element to render or update whenever a particular <script> element is mutated, and all of it is orchestrated by HTMX.

I'm building a webapp[0] for turning Clickup docs into static sites, using CF Workers. There isn't a framework for Workers that has the flexibility I need, so I home-rolled one that only sends rendered HTML over the wire. Async components are supported too, so if I have a particularly data-intensive component the renderer just inlines a tiny JS script that sends a request to the worker again, which then returns just that component in HTML.

Could be worth releasing on its own as a GitHub project!

[0] https://intenso.app

Well I'm glad I've discovered HTMx with this thread, I will try it out with my next project, really tired of SPAs and their bulkiness
You can also go to the extreme of "jpeg over the wire". Your "web browser" could probably be implemented in <1000 lines of of code ;) No state, no cookies, no million lines of bundled JavaScript.
s.gif
If a "real" browser is used that needs javascript to request a jpeg of a size appropriate for the screen.

There might be something that's good enough through css, not sure.

s.gif
Little problems with scrolling but constant updates when a page is resized (changes in layout) - maybe it's worth it...
All companies using Elixir / LiveView, there are quite a few
s.gif
I had a job writing Elixir but it was a terrible fit. Most Elixir jobs want people with multiple years of Elixir experience and I have 8 months, lol. I do have an interview lined up with an Elixir shop, though.
For those mentioning frameworks that update the page by getting HTML from the server and patching it into the page: how do you deal with server-client skew?
I work for a B2B SaaS and we use Ruby on Rails with Hotwire and it's great!

Almost zero JS (no Vue.js, no React, or else).

s.gif
Are you hiring? lol. I'm a rails dev who shifted over to Elixir for a bit, but I'm currently building a project with Hotwire.
FWIW most of the companies using Phoenix (Elixir) that I've talked with are sending HTML over the wire, either with LiveView or traditional Views.
s.gif
I used to work for one, but many companies using Phoenix want more years of Elixir experience than I have.
Been working on a html over the wire library in Go: https://github.com/livefir/fir. It mostly works but still work in progress
I'm building a completely native HTML spa app over at lona.so (just html + js web components and i bundle it myself). Still very much so early days but check it out!
Fresh does this, but I don't know who's using it in production, other than possibly the Deno people.

https://fresh.deno.dev/docs/introduction

Considering their stack, I'd say probably GitHub?
I was just watching a talk about htmx which is awesome looking. i'm a rails guy myself so i am really interested in using hotwire in some projects. htmx looks like a very nice crossplatform approach.

https://htmx.org/

Here is the talk: https://htmx.org/essays/a-real-world-react-to-htmx-port/

s.gif
Unpoly (https://unpoly.com/) should be mentioned as well. Much like htmx but with more features.
Isn't making a request for almost any user interaction a bit too much?

I am more in favour of BE telling FE what to render. I honestly believe many apps could be simplified with better abstractions than hard coding html into messy components. Not saying it's a great approach for super complex layouts, of course.

s.gif
It depends on the usecases & application reqs. There are times when server-rendered content can have enormous benefits over a SPA.

Check out this djangocon talk where a SaaS product moved from react to htmx. https://www.youtube.com/watch?v=3GObi93tjZI

s.gif
I'm talking about tech like LiveView, Hotwire, LiveWire, Blazor, etc. They use JS (in some cases with websockets) behind the scenes to send small bits of html which are patched into the DOM. The win here is that you can write all your business logic on the server and don't need an intermediary API for your frontapp to talk to your backend app, you just send HTML.

If you're building an where you are going to open up an API, there is a little less benefit, but I've worked on projects in recent years where the API exists solely to be consumed by one client.

When I use apps like this - GitLab - I am struck by how much wasted user time such an approach leads to. Everything is a page refresh

Send me some counter examples? Im a big SPA fan and there’s lots of good examples

s.gif
Everything in a page refresh typically only happens with these solutions as a fallback when Javascript is disabled. And if Javascript is disabled, what do you really expect to happen other than everything is a hyperlink?
s.gif
Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search:

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK