Ad

What Is The Difference Between “server-rendering” And Generating Strings Of HTML In The Server?

- 1 answer

When libraries like React talk about "server-rendering", can I simply understand it as that it generates strings of HTML from representations of DOM elements such that when the browser sends a XMLHttpRequest the server returns a string of HTML (rather than a string encoding some JSON object) and we can just append that into a part of the page? Or does "server-rendering" do a lot more than simply generating strings of HTML?

My understanding of the term rendering is that of drawing lines on a screen. So I'm having trouble understanding the nature of "server rendering".

Suppose I have a website with static content (e.g. a blog), page-rendering-performance-wise, is there any advantage in using tools like React in the back-end on a node server for "server-rendering" instead of having a static server (using a static-site generator like Jekyll)?

Ad

Answer

Server rendering generates the entire page on the server.

This is used so that:

  • The site works even when the JavaScript fails
  • The first time a page is requested in a session, the complete, correct page is loaded (as opposed to loading the homepage and then editing it with JavaScript, which introduces a performance penalty as additional HTTP requests are required).

Suppose I have a website with static content (e.g. a blog), page-rendering-performance-wise, is there any advantage in using tools like React in the back-end on a node server for "server-rendering" instead of having a static server (using a static-site generator like Jekyll)?

No. React style server rendering is as a backup to massively ajaxified SPAs. It is there to counter the drawbacks of not using simple static pages.

Ad
source: stackoverflow.com
Ad