DEV Community

Cover image for Everything you need to know about server side rendering
Anjan Shomooder
Anjan Shomooder

Posted on • Updated on

Everything you need to know about server side rendering

In this blog, I will explain everything you need to know about server-side rendering.

I have created a video about it already. Feel free to check that out. And if you like the video then don't forget to SUBSCRIBE to my channel.

How does server-side rendering work?

  • Abstractly There are two entities on the internet. One is the Client and another one is Server.

  • First, the client(browser) sends a request to the server.

  • Server then check the request and sends the HTML file as a response.

  • Browser starts parsing the HTML from top to bottom. When the parser sees the link tag for CSS it blocks the parsing process and starts downloading the CSS files. Then it starts parsing the CSS.

  • After the CSS parsing is completed, the parser starts parsing the HTML again. As the parser parsing the HTML, the browser dom gets pained with content. Also with styles. Because the CSS is already parsed. That is why we put the CSS link tag at the top part of the HTML.

  • After the dom is pained with the content, your webpage is now viewable. Then the parser comes across the script tag at the bottom of the HTML. Now the browser will start downloading the JavaScript and then will parse the JavaScript.

  • The JavaScript might be big and might take some time depends on how big the files are. Parsing Javascript is a heavier task than parsing HTML and CSS. That's why we put the script tag at the bottom of the HTML.

  • After the parsing is completed, the webpage is now both viewable and interactive.

This is a visual representation of the server-side rendering process with react.

Alt Text

Server Side Rendering Pros

  • Great SEO. Because the content is already present on the HTML.

  • Initial load is fast. Not the whole application data is served by the browser. Only the necessary data for the page is sent.

  • User doesn't have to see a blank page on the initial load. Because the content is rendered by HTML not JavaScript.

  • No need for external libraries or frameworks.

Server Side Rendering cons

  • Frequent server calls.

  • Slow navigation to any routes.

  • Page refresh while visiting any routes (not necessarily).

  • Bad user Experience when data changes frequently.

So, that's all you need to know about servers side rendering I guess.

Shameless Plug

I have made a video about how to build a carousel postcard with React, Material-UI, and Swiper.js.
If you are interested you can check the video.

You can also demo the application form here

Screenshot of Insta Carousel

Please like and subscribe to Cules Coding. It motivates me to create more content like this.

If you have any questions, please comment down below.
You can reach out to me on social media as @thatanjan .
Stay safe. Goodbye.

About me

Why do I do what I do?

The Internet has revolutionized our life. I want to make the internet more beautiful and useful.

What do I do?

I ended up being a full-stack software engineer.

What can I do?

I can develop complex full-stack web applications like social media applications or e-commerce sites.

What have I done?

I have developed a social media application called Confession. The goal of this application is to help people overcome their imposter syndrome by sharing our failure stories.
I also love to share my knowledge. So, I run a youtube channel called Cules Coding where I teach people full-stack web development, data structure algorithms, and many more. So, Subscribe to Cules Coding so that you don't miss the cool stuff.

Want to work with me?

I am looking for a team where I can show my ambition and passion and produce great value for them.
Contact me through my email or any social media as @thatanjan . I would be happy to have a touch with you.


Blogs you might want to read:

Videos might you might want to watch:

Discussion (15)

redbar0n profile image

No need for external libraries or frameworks.

Really…? NextJS, NuxtJS etc…

thatanjan profile image
Anjan Shomooder Author

Thank you very much for your interest.
I believe you can build a website with vanilla html and css and nodejs. You don't need external framework.

redbar0n profile image

Yes. But is it a pro of SSR?

Trying to do SSR without a library or framework was one of the famous regrets of Max Stoiber when he built Spectrum:

Regret 2: Not using Next.js ... Turns out, building your own production-ready SSR setup is tough. It takes a lot of work and it is difficult to provide a good experience, for both developers and users.

ipankajkumar profile image
Pankaj Kumar

That's what I thought.
Next.js popped up in my mind the moment I read SSR.

ivanjeremic profile image
Ivan Jeremic • Edited

I'm all for CSR, the compute power goes up everywhere and I also think Google and other search engines should adapt to us, I know they try to promote ssr more but fact is we do ssr only to make google happy, SEO is not impossible with CSR and it does work only it can take a bit longer to get indexed thats all. Also if you think about it it just makes sense because on every device we ship the code like mobile apps and desktop apps but on the web we should not ship it? I think doing CSR only and SPAs will make the web better just think about how much complexity it removes from web-apps.

peerreynders profile image

the compute power goes up everywhere

The Mobile Performance Inequality Gap, 2021

Forget Moore’s Law—Chipmakers Are More Worried About Heat and Power Issues

  1. You have no control over how much compute power there is at the other end.
  2. You have no control over the connection quality to the other end.

The resilient approach is to prioritize information (i.e. HTML) over everything else.

martinkr profile image
martin krause

Great article! Especially the pro and con list of Server Side Rendering!

If you wondering if you should choose Server Side Rendering for your next.js project and are looking for more details which type of rendering are available in next.js, please take a look at my article:

I also like the concept of your videos - keep up the good work!

thatanjan profile image
Anjan Shomooder Author

I am glad that you have liked this article.
I have also read you article. That one is great

redbar0n profile image

Frequent server calls.

Really..? How does SSR give more frequent calls than without it?

thatanjan profile image
Anjan Shomooder Author

I believe that in csr, all application data comes to client on initial request.
But with ssr, you need to send request every time you change the route.
That's why I wrote "frequent server calls"

redbar0n profile image

I believe that in CSR, all application data comes to client on initial request.

Actually, it doesn't. Unless you use Relay, or Streaming SSR which is used by the library/language MarkoJS and in the upcoming release of React 18. Currently, in SPA apps like built with React, the client downloads JS in the first request, which then executes to download the application data in a second request.

It's true that with SSR then routing is on the server and you have to send a request for every page. But in an SPA you don't necessarily have to change page that often, as you could morph the page you are on, by swapping components in and out.

hamzafadil75 profile image

alright, but there's a lot of libraries are not compatible with that, and you should choose suitable framework or libraries to work / or code correctly without any problems, i'm saying that because i had a conflict with the suitable framework on the project ( like primefaces...... )

redbar0n profile image

Typo: «Not the whole application data is not served by the browser.«

thatanjan profile image
Anjan Shomooder Author

Thank you for letting me know. I will fix that.

sintomaticonegativo profile image
Gianluca Tuscano

I'm using a VPS for Blender rendering, does it mean that I'm doing server side rendering?