Deno makes the case for server side rendering

Deno makes the case for server side rendering

Deno, maker of an JavaScript/Typescript runtime for use outside the browser as an alternative to Node.js, has published a rationale for applications that do server side rendering (SSR) rather than relying on the browser client (Client-side rendering or CSR).

“Now, a webpage can be a full-blown app, pulling in data from multiple sources, doing on the fly manipulations, and allowing an end-user full interactivity. This has greatly improved the utility of the web, but at the cost of size, bandwidth, and speed,” claims Deno product marketing manager Andy Jiang, referencing statistics from Web Almanac that show a near-400 percent increase in page weight, the size of the resources downloaded by the browser, between 2012 and 2021. “We’re on an upward trajectory that shows no sign of abating,” the Web Almanac report said.

According to Jiang, the result is “terrible UX, slow loading times, and a lack of interactivity until everything is rendered.” We should note though that Deno is hyping its own approach, where  most code runs server-side on Deno; and that the notion of sharing rendering duties between client and server is familiar even in the React world with initiatives like React Server Components.

Modern web development offers a wide range of choices over where to render HTML including the notion of isomorphic frameworks where there is a virtual document object model (DOM) on the server that matches that on the client, so JavaScript can manipulate the DOM on the server and send the result to the client as HTML.

“Writing isomorphic JavaScript means a smaller code base that is easier to reason about,” said Jiang; though giving developers choices over SSR versus CSR can also add rather than remove complexity in web development. “I prefer to use client-side rendering everywhere so that I don’t have to switch between two different modalities and maintain two sets of tooling (or worse switch in the middle of a project!),” said a developer on Hacker News, responding to Jiang’s post.

CSR also has distinct advantages including reducing server load and providing a smooth user experience once the assets have arrived.

The fastest way to server web pages is static HTML, using not server-side rendering but a static site generator such as Gatsby, Jekyll or Hugo. The catch is that dynamic content such as live data is then retrieved via JavaScript APIs, hence the JAMStack (JavaScript, APIs, Markup), which means that the performance of the microservices delivering those APIs is critical, as is that of the additional JavaScript to render that data on the page.

A counter-argument to Jiang is that tilting too far towards SSR is a waste of the capabilities of modern web browsers, which now extends to WebAssembly enabling developers to write in the language of their choice – including C#, Rust, Java and Go – whether running in the browser or on the server.