Is it just for the sake of speed for the user to immediately see the HTML code? I understand that for the server you can use not only NODE.JS but also Java.

What will it look like if the project is big? There will be no porridge with java, js code? Has anyone seen big projects in such a bundle?

  • For search engines. - andreymal
  • @andreymal, that is, people build isomorphic applications just to please the search engines? Not a big complication for one task - vkovalchuk88
  • sometimes it’s different in any way, it even happens that the search bot has completely personal content - Stranger in the Q
  • @StrangerintheQ I, for example, do not need search engines at all, I need speed. - vkovalchuk88

1 answer 1

Is it just for the sake of speed for the user to immediately see the HTML code?

Yes, basically, this is done in order to reduce the drawing time of the initial page. The fact is that pages of applications built using React contain little HTML and load a lot of javascript code. After downloading javascript page, as a rule, loads data from the server and after that, in fact, draws the page (Rendering, by the way, is not the fastest operation). While javascript not loaded and the data is not received, the user will see a blank page. On the other hand, if the server gives the finished page, then firstly, it seems that the page loads faster, and secondly, you can save on one or more requests to the server, since all the necessary data is already loaded. It's worth keeping in mind that the browser will still load javascript, and after loading React will create a virtual DOM page, but since it matches the code of the generated page, React will not make any changes (no need to redraw the page). In the worst case, part of the page may change after downloading the updated data, but usually this is not noticeable to the user.

It is believed that the server can generate pages faster than the browser, but I think it depends on which server and which computer the user has. In any case, the advantage of generating a page on the server will be the ability to cache the page by the server, which will give it away almost instantly.

There will be no porridge with java, js code

No, it will not, although it will add some difficulties. But there's nothing you can do, either quickly or difficult.

  • Thank! The first good answer to this topic. And tell me, please, if all the scripts are already loaded, but the page changes completely (from test to output, for example) - does it have to use server rendering in this case? - OO
  • @OO something I did not understand the question. - Mikhail Chibel
  • I understand correctly that when a user comes to our website for the first time - we generate html with associated scripts and send back? Next, react itself is responsible for the dom. However, if the dom has changed drastically - instead of a page, for example, personal, account, there should appear a page for a general chat - how best to do it - build it on the server side and send ready html via Ajax or form it with React forces on the client side? Thank! - OO
  • The user requests the page and you generate on the server and return the page as it should be, that is, not that you always return the home page but return what the user requested. If the url bala.com/account then the returned content should contain a personal page. If the user then clicks on a link for example on the list of products, then the reactant will redraw the page without reloading - Mikhail Chibel