I've just gotten started with web development, particularly Reactjs, which introduces "client side rendering." I think I understand the concept of client vs server side rendering, but I don't exactly know how to understand these concepts pragmatically.
For example, when I have <img src="airplane.png" />
, is this image being loaded client side or server side? IE, does the server return the image as part of the original request, or does the image get loaded from the client by making another request to the server after the HTML has been served? If I am loading a large amount of images, would I want them to be loaded client side or server side?
Thanks!
Yes. Server-side rendering is better because the factors like sending initial requests and performance are a bit faster than client-side rendering and pre-rendering. It is simple and does not require round trips to the server.
When developers talk about client-side rendering, they’re talking about rendering content in the browser using JavaScript. So instead of getting all of the content from the HTML document itself, you are getting a bare-bones HTML document with a JavaScript file that will render the rest of the site using the browser.
Server-side rendering or SSR is the conventional way of rendering web pages on the browser. As discussed above, the traditional way of rendering dynamic web content follows the below steps:
This approach makes it easier to design an HTML page, everything from the server, a good way to start playing around this is with PugJS. Client-side rendering (CSR) allows the website to be updated in the browser when navigating to different pages the content is rendered by the client-side (browser).
It's the latter case. The respective tag will be inserted into the DOM of the page and the browser will make another request to the server (or to wherever the image is hosted - it doesn't have to be your server) for the contents of that image.
The term client-side vs server-side rendering refers to where the document structure is computed. In the latter (and classic case) the server builds a whole document as a result of the request, while in the former it builds a skeleton document and it's up to the application logic on the client side to construct the document as the application runs. Of course in server-side rendering, you'd at some point begin modifying the DOM as well in order to make interactive applications, so the delineation is not as clear cut as that.
You can provide the image as a data URL which embeds the contents of the image as an URL, and which will be downloaded in the body of the initial document request. Or sometimes in an attached CSS file. But that's useful for small images which don't get used that often (svg icons or things like that).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With