{"componentChunkName":"component---src-templates-blog-post-js","path":"/development/csr-and-ssr/","webpackCompilationHash":"f92dbf25810602c1889e","result":{"data":{"site":{"siteMetadata":{"title":"Web Devlog","author":"RossenaHuh","siteUrl":"https://github.com/rossenahuh","comment":{"disqusShortName":"RossenaHuh","utterances":"rossenahuh/my-dev-blog.git"},"sponsor":{"buyMeACoffeeId":"rossena"}}},"markdownRemark":{"id":"65330625-9a5c-58a3-8b14-e7d6d34d48a5","excerpt":"How Server Side Rendering works?We load up .html pages on the server, then the server turns them into useful documents on the user’s browsers.\nSSR is the traditional rendering method and it worked just as fine until the webs became so complicated and interactive.A bit faster at…","html":"<h2 id=\"how-server-side-rendering-works\"><a href=\"#how-server-side-rendering-works\" aria-label=\"how server side rendering works permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>How Server Side Rendering works?</h2>\n<p>We load up .html pages on the server, then the server turns them into useful documents on the user’s browsers.\nSSR is the traditional rendering method and it worked just as fine until the webs became so complicated and interactive.</p>\n<ul>\n<li>A bit faster at the initial reqeust</li>\n<li>Renders the entire new page each time users visit a page though the page has only subtle differences, whcih leads to the slightly slower load for all subsequent pages.</li>\n<li>Seach engines can crawl the site for better SEO</li>\n</ul>\n<h2 id=\"hows-client-side-rendering-works\"><a href=\"#hows-client-side-rendering-works\" aria-label=\"hows client side rendering works permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>How’s Client Side Rendering works?</h2>\n<p>A more recent kind of rendering method where the contents are rendered in the browser via a JavaScript framework. CSR takes two round trips to the server. First request is to get the bare-bones HTML source code which has very little indexable HTML in it, then in the second request, the rest of the site will rendered from .js file using browser.</p>\n<ul>\n<li>Slow initial load</li>\n<li>Once the initial request is complete, it offers blazing fast experience since the users will only be loading a mall section of the page instead of loading the entire page.</li>\n<li>Low SEO if not implemented correctly</li>\n</ul>\n<h2 id=\"seo-implications-of-ssr-and-csr\"><a href=\"#seo-implications-of-ssr-and-csr\" aria-label=\"seo implications of ssr and csr permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>SEO Implications of SSR and CSR</h2>\n<p><strong>How Google Search Engine works</strong></p>\n<ul>\n<li>The first wave requests source code, crawls and indexes present HTML</li>\n<li>It returns for the additional indexable content when the pages are fully rendered and this takes from a few hours to a few weeks.</li>\n</ul>\n<p>The initial page with CSR will be like this:</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">&lt;html&gt;\n&lt;head&gt;\n  &lt;script src=&quot;js-framwork.js&quot;&gt;&lt;/script&gt;\n  &lt;script src=&quot;app.js&quot;&gt;&lt;/script&gt;\n&lt;/head&gt;\n&lt;body&gt;\n  &lt;div id=&quot;root&quot;&gt;&lt;/div&gt;\n&lt;/body&gt;\n&lt;/html&gt;</code></pre></div>\n<p>app.js will have all the HTML contents in JS as strings. Before the page is fully rendered, the search engine can’t locate any stuff from body.</p>\n<p>For SSR, having HTML content in the source code, the search engine can request, crawl and index it during the first wave. Thus it is advantageous to appear in search results in short time.</p>\n<p>With CSR, since the content is not rendered until the page is loaded on the browser, the web page will have to wait for the second wave when the indexable content is finally available.</p>\n<p>But the thing is not every search engine employs the JS rendering capabilities like Google does. Resulting in web developers struggling with thier CSR not being ranked in search results.</p>\n<h2 id=\"solution-for-this\"><a href=\"#solution-for-this\" aria-label=\"solution for this permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Solution for this</h2>\n<ul>\n<li>SSR for the first page load</li>\n<li>CSR for all subsequent page loads</li>\n</ul>\n<br>\n<br>\n<br>\n<p><em>Sources</em></p>\n<p><a href=\"https://medium.com/@benjburkholder/javascript-seo-server-side-rendering-vs-client-side-rendering-bc06b8ca2383\">https://medium.com/@benjburkholder/javascript-seo-server-side-rendering-vs-client-side-rendering-bc06b8ca2383</a>\n<a href=\"https://medium.com/@adamzerner/client-side-rendering-vs-server-side-rendering-a32d2cf3bfcc\">https://medium.com/@adamzerner/client-side-rendering-vs-server-side-rendering-a32d2cf3bfcc</a>\n<a href=\"https://www.freecodecamp.org/news/what-exactly-is-client-side-rendering-and-hows-it-different-from-server-side-rendering-bd5c786b340d/\">https://www.freecodecamp.org/news/what-exactly-is-client-side-rendering-and-hows-it-different-from-server-side-rendering-bd5c786b340d/</a></p>\n<br>\n<br>","frontmatter":{"title":"Sever Side Rendering & Client Side Rendering","date":"July 17, 2019"}}},"pageContext":{"isCreatedByStatefulCreatePages":false,"slug":"/development/csr-and-ssr/","previous":{"fields":{"slug":"/development/rest-api/"},"frontmatter":{"title":"The difference between API and REST API","category":"Development"}},"next":{"fields":{"slug":"/development/what-are-cicd-and-devops/"},"frontmatter":{"title":"What are Agile, DevOps and CICD","category":"Development"}}}}}