Skip to content
the poor coder

server side rendering

Poor Man
Published
Reading time
1 min read
On this page

Server Side Rendering Explained#

Server Side Rendering (SSR) is the process of rendering the HTML on the server before sending it to the client’s browser. This approach provides several benefits over client-side rendering, such as faster page loading times, better search engine optimization, and improved accessibility.

How does SSR work?#

When a user requests a page from a website that uses SSR, the server generates the HTML markup for that page and sends it to the client’s browser. The browser then displays the content to the user. This approach differs from client-side rendering, where the browser downloads a minimal HTML file and JavaScript bundles, and then the JavaScript code fetches and renders the content dynamically.

One of the main advantages of SSR is faster initial page loading times. Since the server generates an HTML page with all the content, styles, and scripts, there’s no need to wait for JavaScript to download and execute before displaying the content. This results in a quicker time-to-first-meaningful-paint (TTTFP) and a better user experience.

Implementing SSR#

There are several ways to implement SSR, such as using server-side frameworks like Next.js, Nuxt.js, or Angular Universal. These frameworks provide an easy way to set up SSR by abstracting away some of the complexities of the process.

Text
const express = require('express');
const app = express();
const port = 3000;

app.get('/', (req, res) => {
  res.send('Hello World!');
});

app.listen(port, () => {
  console.log(`Server listening at http://localhost:${port}`);
});

Alternatively, you can implement SSR manually by using a server-side language like Node.js or PHP to generate the HTML markup for your pages. This approach requires more coding, but it provides more flexibility and control over the process.

Conclusion#

SSR is a powerful technique for improving website performance, accessibility, and search engine optimization. By rendering the HTML on the server, we can provide a better user experience and improve our website’s visibility in search engines.

Keep going

2023

how to sort an array

How to Sort an Array If you have an array and you want to order its elements in a specific way, you need to use a sorting algorithm. There are several sorting algorithms available, but two of the most commonly used are…

javascript2 min read
2023

jquery mobile or desktop

jQuery Mobile or Desktop? As a web developer, I have had some experience with both jQuery Mobile and jQuery Desktop. Both frameworks have their pros and cons, and which one to use really depends on the specific project…

javascript1 min read
2023

node.js folder structure

Node.js Folder Structure If you are new to Node.js, it can be daunting to create a folder structure that will work for your project. The structure you choose will depend on the size and complexity of your project. Here…

javascript1 min read
ESC