A Closer Look at Client-Side & Server-Side Rendering

Every developer is familiar with the age-old dilemma: should I render a site from the client-side or the server-side? Since the invention of search engines, the conventional...

Fiona Gurtiza
Fiona Gurtiza July 28, 2020

Every developer is familiar with the age-old dilemma: should I render a site from the client-side or the server-side?

Since the invention of search engines, the conventional method of setting up HTML onto a screen took place through server-side rendering (SSR). Back then, this was the only way to serve web pages, which displayed only static images and text. 

But times have changed. Websites are a lot more complex these days because you can use them to send messages and make transactions. In fact, much of the modern web is built with more flexible client-side rendering (CSR) techniques because they offer a way to create more dynamic, scalable websites.

In particular, the advent of JavaScript (JS) frameworks made it possible to render dynamic content right from the browser. The result: faster loading web pages that translate into a seamless user experience. 

Over the years, it’s no surprise that SSR has taken a backseat to give way to rendering web pages through CSR. And this raises the question: how do you decide on which approach works best?

Just like other aspects of software development, it all depends on what you plan to do with your website. In this article, we take a closer look at SSR and CSR so you can decide on the best route forward. 

What is JavaScript SEO?

At its core, JavaScript SEO is a part of technical SEO that aims to make JS-heavy websites easier to crawl and index. The goal is to make these websites easier to find so they can rank higher on SERPs.

Sometimes, JS gets a bad rap because it offers a different approach from what most SEOs are used to. In some cases, people end up overusing JS for situations that call for a better solution. 

At the end of the day, JS can’t be parsed progressively unlike HTML and CSS. It can also get a little heavy when it comes to page load and performance. So by resorting to JS, you could be trading in performance for functionality.

SSR & CSR: The Basics

How does JS relate to SEO, you may ask? It all boils down to how Google crawls and indexes a site.

Search engine crawler bots don’t function as full-fledged web browsers because they need to move through a vast web of content. This means that some of these bots don’t run JS or support CSR. That’s why SSR used to be recognized as the best content rendering method for ensuring HTML content was crawled properly by search engine bots. 

Before we continue, let’s take a closer look at the two predominant types of rendering.

Server-Side Rendering

SSR is the most common method of displaying content onto a screen. It works by converting HTML files on the server into useful info for the browser. 

Here’s how it works. When you visit a website, your browser makes a request to the server. Once this request has been processed, your browser construes the content and displays the page. The entire process of fetching data from the database, creating an HTML page, and sending it back to the browser takes place in just a few milliseconds.

If you decide to visit another web page, the process simply repeats itself. Keep in mind, however, that this could increase server load and consume unnecessary internet bandwidth.

Client-Side Rendering

CSR, on the other hand, is a relatively new approach to website rendering. It didn’t become popular until JS libraries started incorporating the method into their style of development.

Using CSR lets developers create websites rendered entirely in the browser using JS. This means that instead of having a different HTML page per route, CSR sites create each route dynamically on the browser. You might notice that the initial page load for CSR may be a bit slow, but it picks up with faster load times of subsequent pages.

Unlike in SSR, communication with the server only takes place when obtaining run-time data. On top of that, CSR eliminates the need to reload the entire UI after every call to the server. 

In case you’re still feeling confused, it helps to think of SSR as you driving over to the supermarket every time you feel hungry to grab food. With CSR, you get to visit the supermarket once where you spend buying all the food you need for the week. Then, whenever you feel hungry, all you need to do is go through your stocks or open the fridge.

Now that that’s clear, we’ve provided a summary of the pros and cons of each method below:

Understanding the Difference

At a glance, it’s pretty clear that SSR and CSR are different in the way they process content. To understand this better, let’s pick apart their three main differences.

Difference #1: Page Load Times

Page load time describes the period between sending a request to the server and rendering it to the browser. Keep in mind that longer page load times could have a negative impact on your site’s UX. 

Initial Load Time

Initial load time is the average time it takes a user to load your site for the first time. When using CSR, the browser loads base HTML, CSS, and all required scripts before compiling HTML to usable content on the browser. As a result, you can expect SSR to load up the first page a lot faster.

Subsequent Load Time

Subsequent load time describes the time it takes to navigate from one page to another. For this scenario, all of the supporting scripts have been loaded in advance for CSR, which translates into shorter page load times.

On the other hand, SSR follows the same request cycle for first-page load time. So when placed side-by-side, CSR responds faster when loading subsequent web pages. 

Difference #2: Caching Impact

Caching is a technique that involves storing copies of files in a cache (or a temporary storage location) so they can be accessed more quickly. Browsers and web servers apply caching mechanisms for reusable scripts on a user’s machine. As a result, you can expect an improvement in overall load times for SSR and CSR. 

There is still one key difference, however. As long as no lazy loading module is required, CSR-based web apps can run even without the internet. So once the page has been loaded, there’s no need to send requests to the server anymore.

For SSR, requests to the server will always be sent, which yields a higher load time. But on the bright side, caching mechanisms can help improve rendering speeds since the scripts are retrieved by the browser from the cache.

Difference #3: Impact on SEO

Optimizing your site for SEO is a must. But before this can work, your web page should reflect the right metadata for search engines. After all, search engines like Google use automated bots to crawl your site’s metadata.

When using CSR, the content on your site is automatically generated through JS. This means that changing metadata from one page to another relies on JS execution. In turn, it requires the use of plug-ins or library modules to set the metadata for each page so they’re rendered on the client-side.

Meanwhile, with SSR, complete pages are compiled with the right metadata. After receiving the final HTML content, they’re sent to the front-end. This method ensures that the page metadata remains accurate whether or not search engine crawlers allow the use of JS or not. 

With that said, SSR sites are more SEO-friendly than their CSR counterparts.

When to Use SSR & CSR

Until recent years, developers were only presented with one option for rendering: SSR. But ever since CSR came into the picture, you might be wondering which approach works best for your website or app. 

Again, it depends on the situation. Here’s what we mean:

Scenario #1: Dynamic Content Loading

Servers often reside on machines with high computing power and faster networking speeds. That’s why servers can be counted on for the extra juice needed to process large requests. So when you think about it, it makes sense why fetching content on the server-side is a lot faster.

Machines on the client end, however, feature limited computing power. This translates into more time required to complete content rendering. Therefore, if your site involves repeated dynamic content rendering, SSR is the better choice.

Scenario #2: Web App UX & Site UX

Web applications and websites are two different formats of web content. Web apps require more interaction since users need to perform tasks such as data entry and report generation. A website, on the other hand, is simply a page that offers provides info about a business.

With that in mind, CSR works best for web apps because it can help ensure that each click doesn’t take too long. When it comes to websites, however, SSR fares better than CSR because it ensures the right metadata for searching engine bots. On top of that, caching mechanisms can help speed up rendering when users navigate from one page to another.

The Best of Both Worlds

Now that we know the difference between SSR and CSR and when each method should be used, you might be wondering if there’s a way to fuse SSR’s quick initial page loads with CSR’s SEO performance. 

The answer is yes. Some modern frameworks operate under a hybrid approach, such as GatsbyJS and Next.js. These frameworks load initial pages with SSR then use CSR to reload subsequent pages. That way, you get the best of both worlds.

But even without adopting a modern framework, choosing the right rendering method will depend on what works for you. Just make sure to consider the consider SSR and CSR from a functional and practical point of view. Making the wrong call could cost you in terms of site redevelopment or code management. 

If there’s anything else you need, you can count on our web development team for a site that delivers real impact. Get started when you partner with Growth Rocket today.

More From Growth Rocket