What Is Client Side Rendering?

Client side rendering (CSR) is a web development approach in which a webpage’s content is generated (rendered) in the browser using JavaScript, rather than being pre-rendered on the server. 

In this case, when a browser requests a webpage, the server responds with a minimal HTML shell, along with the necessary CSS and JavaScript files. The browser then assembles and renders these files into the webpage that is displayed to the user.  

Client side rendering contrasts with server side rendering, which refers to the process of rendering the webpage on the server before sending the rendered HTML page to the browser.

What Is the Minimal HTML Shell?

The minimal HTML shell itself refers to a file containing the basic HTML code that the browser needs to structure the webpage. This code does not contain the content of the webpage. Instead, it has just enough code to load the JavaScript and CSS required for the webpage. 

The minimal HTML shell loads quickly. However, the page is not meaningful or complete until the browser executes the JavaScript. It is even common for users to see a blank screen until the JavaScript file completes loading and rendering the content. 

For example, the code below is a minimal HTML shell:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>My post</title>
    <link rel="stylesheet" href="styles.css" />
  </head>

  <body>
    <div id="root"></div>
    <scrіpt src="bundle.js"></scrіpt>
  </body>
</html>

In the above code:

  • <div id="root"> is a placeholder where JavaScript will inject the actual content
  • The JavaScript file (e.g., bundle.js) contains the app logic, components, and code for fetching data

Importance of Client Side Rendering

Client side rendering generates web content directly in the browser using JavaScript. This enables the browser to dynamically load or update elements on the page without needing to reload the entire webpage.

This makes client side rendering great for pages that update in real-time, as well as dynamic websites that display different content depending on the user. This is why many social media, streaming, messaging, e-commerce, and collaboration sites use client side rendering over server side rendering.

Overall, client side rendering leads to an improved ユーザーエクスペリエンス on such sites, as they can easily update the page as new information is received or the user interacts with them. 

Difference Between Client Side and Server Side Rendering

Client side rendering (CSR) and server side rendering (SSR) are two rendering systems that differ mainly by where the HTML content is generated. 

In client side rendering, the browser receives a minimal HTML file that includes references to external JavaScript files. The browser then downloads and executes the JavaScript, which dynamically generates and renders the webpage content.

In contrast, server side rendering generates the HTML page on the server and sends it to the browser. The browser then displays the content immediately while executing the relevant JavaScript code. 

This makes pages rendered on the server side faster than those rendered on the client side. Such pages are also easier and quicker to crawl as web crawlers do not typically need to expend additional resources to access their content.

However, these benefits do not apply to dynamic and live webpages, which require more frequent updates. If we render such pages on a server, the server would repeatedly need to generate new pages in order to present the user with the new or updated information. 

This will consume server resources and negatively impact the user experience. Such pages are loaded on the client rather than on the server. 

Overall, server side rendering is typically the best option for SEO, as it ensures increased page load speeds for people and search engines.  WordPress sites even load on the server by default, although some elements can be configured to load on the browser. 

Still, most modern sites use a mix of client side and server side rendering. However, developers typically lean towards one over the other. 

Benefits of Client Side Rendering

Client side rendering provides bloggers, developers, and users with some benefits over server side rendering. We will detail some of them below. 

1 It Reduces the Server Load

Client side rendering shifts rendering work from the server to the client. This reduces the server’s load as it does not need to expend resources on rendering the webpage. 

This is particularly beneficial in specific situations, such as during periods of high traffic, which can cause servers to slow down or even crash. In such cases, the server is less likely to crash since it is not rendering webpages. 

2 It Ensures a Better User Experience for Live Sites

Dynamic and live webpages are better rendered on the client side than on the server. This works because client side rendering uses JavaScript to render content directly in the browser.

This approach allows for quick updates and dynamic interactions without requiring the entire page to be reloaded. However, it can become detrimental with static sites that do not require constant updates.

3 The Sites Have Improved Responsiveness

Webpages rendered on the client side are typically more responsive than those rendered on the server. So, user actions such as clicking buttons or switching tabs feel faster and smoother than they do on pages rendered on the server. 

Disadvantages of Client Side Rendering

Client side rendering also comes with drawbacks that make it inefficient or less desirable in certain situations. Below are some of the most common issues with it. 

1 It Has Poor SEO by Default

Search engines may struggle to index content that is fully rendered on the client side. This is because the initial HTML contains little or no meaningful content. Therefore, crawlers may miss important information, which can result in indexability issues.

2 It Completely Depends on JavaScript

Client side rendering relies heavily on JavaScript to display and manage content. If JavaScript fails to load or is disabled in the browser, the page may not function or appear at all. This makes client side rendering less reliable than server side rendering.

3 It Has a Slower Initial Page Load Speed

Pages loaded on the client side are slower than those loaded on the server. This is because pages that load on the client side typically receive a minimal HTML file without any content. 

While this allows the browser to structure the page, it delays the content on the page from being displayed. Therefore, it is normal for users to be presented with a structured but empty webpage while the browser downloads and executes the necessary JavaScript code to display the page’s content. 

4 It Has a Longer Time to Interactive (TTI)

The time to interactive (TTI) is an SEO metric that refers to the time it takes for a user to be able to interact with a page. It is typically longer on pages that load on the client side than on those that load on the server side.

This is because pages that render on the client side must first download, parse, and execute JavaScript before becoming interactive. This delay can negatively impact the user experience and can affect SEO and performance metrics like the time to interactive.

🇯🇵 日本語