Live data from Hacker News

The absurd complexity of server-side rendering

gist.github.com

181–190 of 395 posts

Re: The absurd complexity of server-side rendering

#181

In Javascript SSR, if you need the same logic on the client and server, define an API module + interface. Make a different API bundle on the server that calls NodeJS functions, file reads, whatever, directly. Make an API bundle on the client that makes AJAX requests to your API endpoints. Now your Javascript can call the same `api.fetchWhatever()` method, and await the result, and it works on the client and server (i…

Double the code. Double the bugs.

Re: The absurd complexity of server-side rendering

#182
post #120

https://htmx.org/ Having spent 36+ years in the computer industry, I consider the advent of htmx to be the first thing in web development to to attempt to pull the industy's head out of it's ass. Don't forget to include a solid remake of css in your project like tailwindcss. It also makes code much more readable.

When fetching from the backend, the docs recommend returning snippets of html instead of JSON. Is it technically valid to return a snippet of HTML with a content type of “text/html”? There’s no standards saying you need !DOCTYPE or a head or body?

Regardless of whether it is standard or not I've definitely worked on sites that worked this way back in the day. Smarty+PHP would generate the beef of the page, then certain components of the page would be pulled in using Ajax requests as the user did things. The browser would not care.

Re: The absurd complexity of server-side rendering

#183
post #99

In this thread: people confusing server rendering (like your old PHP) with SSR (same Javascript codepath for client and server, i.e. Next.js) One is easy, the other is the definition of leaky and crappy abstraction. This article is about the latter technology.

I think you're confused as well. Most frameworks that provide any kind of HTML rendering method can do server-side rendering. The trickiness is making them isomorphic.

> the other is the definition of leaky and crappy abstraction

Well that's just like, your opinion man.

Re: The absurd complexity of server-side rendering

#184

How can a small site like HN possibly work when SSR is so complicated?

Ryan Carniato (@RyanCarniato) have a hackernews clone in every major framework with SSR support. Mostly made on streams as well!

+1, I really enjoy watching his content. His deep dives into certain technologies is truly valuable, if a bit long-winded.

Re: The absurd complexity of server-side rendering

#185

See https://remix.run for a modern, sane, progressive approach to server-based rendering w/ as-needed hydration.

Remix has the exact same issue unfortunately: https://remix.run/docs/en/v1/guides/constraints

This actually bit me multiple times. I started leaking server-side code to the client, which completely turned me off. Also I've been in several arguments with Remix community members as to why middleware is necessary for server-side frameworks and why there needs to be a global state option.

I was going to evangelize them at my current gig... thankful that I didn't go down that route and made my own prototypes. There are solutions (such as implementing your own caching layer) but ugh, why.

Re: The absurd complexity of server-side rendering

#186

> After a fashion, it was decided that sometimes our HTML is best rendered by JavaScript, running in a user's browser. While some would decry this new-found intimacy, the age of interactivity had begun. I didn't get the memo when this was decided, and I'm still unconvinced. Let me see if I get this straight: The main reason for client-side rendering is that some web applications don't want to do a full page reload ev…

> The main reason for client-side rendering is that some web applications don't want to do a full page reload every time that there's a non-trivial state change (usually triggered by user interaction).

If that is the reason (I don't know) some element other than would be a much simpler solution.

I had a few ideas just now. It seemed the most fascinating to tie part of the query string to a div.

Then you have your usual

And your url example.com/?foo=demo.html

And from thereon shall only update that part of the url and that part of the document.

If demo.html contains a or it is ignored if the target is a div.

But something like with appropriate targets seems fine(?)

Alternatively the querystring tie can be defined on the element.

Older browsers when hitting will load example.com/?foo=second-demo.html

Re: The absurd complexity of server-side rendering

#187
post #8

Earlier quoted context omitted.

My org just bought a professional bootstrap template. It takes 3 build tools and 1500 node packages just to build the SASS into a CSS bundle. It boggles my mind that this is normal in the front end world.

only 1500? you got lucky! gatsbyjs (React framework) has so many dependencies it breaks GitHub's dependency graph https://github.com/gatsbyjs/gatsby/network/dependencies

This is absolutely absurd. This is ammunition for others to not take the Node.js community seriously.

Re: The absurd complexity of server-side rendering

#188
post #30

I already know I'm off my rocker (and my lawn with that phrasing) but I really wish the browser supported Python as a language instead of Javascript. I can pickle Python, send it to a client, and run it. Combine that with everything else Python 3 has brought to the table and I'd have a language that runs client side that I can depend on and that I love.

The browser doesn’t even have modern JS. Well, I mean it does, but for awhile it didn’t. We consider modern history to be anything past 1815. So in web terms, if you had to section it, modern web history is like maybe 2010 onwards? In those years we transpiled new Ecmascript to old ecmascript.

So, nothing is stoping us from tranpiling Python to new or old ecmascript.

But, I think you’ll see that it won’t solve much. You are just turning one turd into a lesser turd. The problem is fundamentally deeper. The browser and web server tech was not built for app development. That’s the bottom line.

Re: The absurd complexity of server-side rendering

#189
post #55

Earlier quoted context omitted.

> Also, all forum software, which is SSR, despite being 20-30 years old, is usually faster than a SPA. Only because crap tons of hardware got thrown at the problem. I remember when forums were multi-seconds to load each page. It sucked. People complain about reddit a lot, but even on mobile, the reddit website is fast. It may be janky at times, but navigating between comments on stories is under a second, loading mor…

> I remember when forums were multi-seconds to load each page. It sucked. You mean when you had the same internet speed 10 years ago, right...?

I could pull 2 megabytes per second down back in 2000.

I was at 5x that by 2010.

My internet speed didn't really improve from 2010 to 2021, (Comcastic!) then I got fiber. File downloads are faster (800mbit gets binary fast), web pages are about the same.

Servers have gotten faster, but ad tech had made crap slower.

SSR won't help solve ad tech garbage making pages janky.

Re: The absurd complexity of server-side rendering

#190
post #55

Earlier quoted context omitted.

> Also, all forum software, which is SSR, despite being 20-30 years old, is usually faster than a SPA. Only because crap tons of hardware got thrown at the problem. I remember when forums were multi-seconds to load each page. It sucked. People complain about reddit a lot, but even on mobile, the reddit website is fast. It may be janky at times, but navigating between comments on stories is under a second, loading mor…

> People complain about reddit a lot, but even on mobile, the reddit website is fast. only on mobile is Reddit fast.

Pardon me while I load up reddit on my 4 year old $1000 Costco Special laptop.

Yup, that was fast.

OK let me disable ad block.

Under 3 seconds to first render.

Comments appear in under 2 seconds.

Reddit performs very well. The new UI is legit faster. There is a bit of stupid here and there with it, and if you aren't logged in the experience is horrible, but speed is, IMHO, not one of the site's problems.

Post reply on HN