Odd, the article conclusion seems to directly contradict the title.
I've used both approaches over the years and they both seemed to work pretty well. The only differentiator I really noticed was that the single-page-app style (client) seemed to be more elegant on mobile, while the server rendering was easier to split into tabs on desktop browser.
I'm really a tab fanatic so have disliked the last few years of javascript everything on the client, where middle click stops working. Are there any solutions for that, that I've missed?
Actually these client-side / server-side debates always go really really wrong.
Especially these two article's make really really awful assumptions. There are use cases for client-side frameworks. There are even website's or i would call it applications that running behind firewalls that make good usages of such tools.
Also he mentioned two server-side template engine's in the linked article. JSP and ASP especially these two are the worst thing you could do. Mixing Code within your Template is by far worse than using the AngularJS template engine wisely.
I would rather prefer everybody to use mustache (even) on the server. Performance in a template engine is also the least thing you should consider.
I'll take option C) "Both, where appropriate". I'm working on a little side project that uses front end Mustache templating for allowing admins to build out some structured components, I can then reuse those same Mustache templates to render the components serverside for non-admin users consuming the service.
One premise of this article bothers me right off the bat.
I don't understand why, as an application developer, we wouldn't want to offload some of the computational load to clients instead of our own servers. That is a resource that scales far better with the number of users.
If servers only handled data instead of page rendering and so on, we'd need fewer of them to handle larger loads and also be a lot more robust to getting posted on HN or Reddit, etc.
Bottom line in all this quibbling seems to really just be that some people like JS and want to JS-all-the-things. I like JS to some extent, but continue to dislike and resist the rise of JS-all-the-things. And I build rich and complicated applications people use to do their jobs every day.
I prefer server-side templates and rendering hands-down. This makes it absolutely trivial to build HTML for anything just by hitting a URL that represents it. It also makes it trivial to add caching of those fully rendered HTML blobs if desired/needed.
I prefer to keep my JS focused on interactions and behavior, not turning JSON data into UI components. I build most apps with a skeletal JS layer that knows how to grab the right item at the right URL when triggered by a user action, and what part of the page to place the returned HTML into. I find it pretty fun and challenging to see how dumb I can keep JS.
I despise the idea of building dual validation in the client and on the server. Fuck that noise. With a forms library that is tied to my models (something that exists in most mature frameworks), the server near-instantly validates and sends back HTML with errors marked if the form is invalid. Again, JS just has to know to PUT/POST the form, and display the response in the right spot. And those forms still work when you hit them by URL instead of through a fancy JS-ified UI. Makes it damn trivial to build dumb versions of an app that aren't broken and unusable. And I like the idea of being able to replace a backend that only has to keep the contract of returning HTML from an endpoint. Don't even need to modify the client-side JS that responds to user actions if I don't want to. Maybe, at worst, I update some ids and classes if I decide to modify the markup.
I've never joined the bandwagon of server-side JS and Node. Ultimately, I simply can't bring myself to want to use JS as the primary language for my work. Not to mention that JS tooling, npm, and different versions of ES is an abysmal headache that creates way too much mental overhead just to get started. It's nice to be able to pick a language that just runs on its runtime without needing to know or setup whatever the flavor-of-the-month transpiler is that lets me use classes and shit.
JSON is cool as a means of exchanging data with an API. I like that. It's predictable, standardized, and a helluva lot better than SOAP ever was. But I find working with APIs programmatically and providing UIs to humans are wholly different interaction models, and can't help but feel that we keep making presenting UIs to humans increasingly more complex than necessary. APIs provide a predictable interface for exchanging structured data. UIs are meant for interacting with that data.
The guy who thinks client-side rendering is wrong is using ASP and JSP as his example web development systems. Those are outdated technologies. (ASP pre-dates ASP.NET by years). Since he is using outdated technologies as a reference point, I am not surprised he has an outdated perspective on client-side templating.
Client-side templating comes with its own problems and advantages. You might not need or want it. A lot of times though you do.
But the original guy who is against it is so far behind.. give it a year or two when people are taking desktop apps and compiling them to web assembly and running them in web browsers. Then the advantages will be obvious. But that is almost a reality today and that person probably doesn't even know that web assembly exists.
Sorry but people need to try harder not to fall behind.
I don't understand why people think serving a blank or janky page to your users is OK. There's no reason not to serve a completely rendered page from the server side and only enhance the UI with client-side rendering and navigation when there is a user action or other event after page load.
The test case used text in a table, which is an extremely poor example. Modern designs use a lot of images and CSS, where presenting a complete document and stylesheets allows much faster time to render than client-side rendering followed by fetching all those assets and applying styles.
The pain for your users is multiplied by the slowness of mobile devices/networks and the complexity of your UI's layout to render.
I was under the impression that the expressions "experimentally verified" and "is wrong" could never be in the same sentence. ;-)
I'm really confused by this:
> Notably, neither of these pages has any external resources. I wanted to control for that variable and understand the best you could do theoretically with either approach.
That's not the theoretical best in any way. The theoretical best is script tag pointing to a popular CDN, which has been loaded by this or another site before and is already in browser memory when you open this page. Then your page can be basic template+data with no code inlined.
I know this is a vanishingly unpopular opinion these days, but personally I think that if your content can only be rendered by a user-agent with full JavaScript support, your content isn't a fully formed citizen of the Web.
Your content can't be archived properly by the Internet Archive.
Your content can't be accessed by anything user-agent less sophisticated than a full-blown browser.
Your content can't be indexed by a search engine that doesn't have the resources to crawl using full headless browsers.
Your content won't work with tools that attempt to scrape and expand content (think URL expansion on Slack, Twitter, Facebook etc).
(There's a very high chance that your content sucks in widely used screen readers as well)
HTML for content, CSS for presentation, JavaScript for behavior enhancement. Not everything has to be built like Trello.