Why Use Server Side Rendering To Boost Performance and User Experience?

Server Side Rendering

Server Side Rendering (SSR) took a backseat when dynamic JavaScript frontends built in AngularJS went mainstream. Node.js brought JavaScript under the realm of backend development, giving rise to isomorphic coding. AngularJS(v1.X) did not support server side rendering. When React and Angular (v2.0+) came along with first class support for server side rendering and developers realized its full potential, the dynamics of isomorphic JavaScript coding began to fall away from web browsers to Node servers. JavaScript developers realized server side scripting results in better performance and businesses looking to boost their customer engagement followed the suite.

Before digging into how server side rendering improves customer experience to boost engagement and why use should implement it, let’s see how server side rendering and client-side rendering work in real world scenarios. I will introduce the concept of client-side rendering which happens in users’ web browsers. Then I will move to explain the concept of server side rendering and how it is better for business as well as users.

Let’s see what happens when a user hit URL in the web browser

Every web application has two parts: markups and logic. Browsers are champions at rendering markups. In a LAMP stack web app, the logic is in PHP, which the browser can’t render readily and have to rely on an Apache server to render. However, when we talk about isomorphic JavaScript coding in MEAN stack and MERN stack, the browser can handily render logic in addition to markup and application can go about without the need of server side rendering. In case of pure JavaScript applications, SSR is more of a luxury than need.

How server side rendering compares to client-side rendering when a person requests the site:

Client-side Rendering Server Side Rendering
 Server pull HTML files with links to JavaScript  Server-sends “ready to render” HTML files
 Browser downloads HTML  Browser displays a non-interactive page
 Browser downloads JavaScript  Browser downloads JavaScript
 Browser executes framework  Browser executes framework
 Page loads completely  Page become interactive

If you look at the table above, the principal difference between the two is this that in SSR, the requesting person gets a glimpse of the page without any delay. While in CSR, the browser has to download JavaScript and html and execute framework before it could display the page. Therefore, the visitor gets a better user experience with server side scripting.

Benefits of Server Side Rendering

  • Server side rendering boost user engagement

Server side rendering has been around as long as web development. In modern JavaScript frameworks, it solves newer, modern problems that we did not realize we had. Any shift in technology brings fresh challenges and the shift to client-side rendering with AngularJS wasn’t any different. SSR struck no full-stack JavaScript developer although a few developers moving from LAMP technologies felt homesick without SSR. Most developers took CSR in AngularJS as the future of web development because nobody wanted to rerun into the hassles where the entire web page reloads every time something is changed in the View.

Server-side rendering boost user engagement

In fact, when Angular and React reintroduced server side scripting, developers criticized them for being overzealous. Soon dynamic front-ends, interactive content, and smooth mobile app-like user experiences became the standard, but they introduced unnecessary complexities, causing overfed client-side executions with empty loading screens and further performance bottlenecks. That wait time to load a CSR page to SSR page may be milliseconds on a decent internet connect, but it is noticeable enough to look for a less-limiting solution.

“A client running a news portal was experiencing huge bounce rate on his website. This was taking a toll on his Google AdSense revenue. The website was developed in AngularJS. Because of client-side rendering the browser was loading an empty page, which was raising false alarm that the website is not working, making visitors leave the website the very moment.

AngularJS does not support server-side rendering. We upgraded the underlying technology to React and implemented server-side rendering in order to do away with the “empty page” problem. The redesigned website in React brought the bounce rate under the safe limits and inspired client to bring SSR in all his applications.”

  • Better Performance for Page Visitors

Better Perofrmance & Growth

Not every device is same in terms of hardware capabilities or  has latest software. A page rendering on the client side relies too much on device’s hardware capability while rendering. A sub-capable hardware may fail to render the entire page in optimal time, thus, hampering user experience. The bounce rate of a page is directly proportional to its load time. Higher bounce is one of search engine ranking factors and may make Google slightly less prefer your website owing to extended load time. As a result, organic traffic to your website will fall, which will ultimately affect engagement on your website.

Since in server side rendering JavaScript is rendered server side, your users’ devices have little relevance to the load time of your page. Since most servers are capable enough; you will deliver a consistent load time to all the people visiting your website, boosting engagement on your website owing to less bounce rate and a healthy organic traffic.

  • Faster Loading of Page

When I drew comparison between CSR and SSR; I mentioned in SSR, the server sends “ready to render” HTML files to instantly load your website on the browser. In CSR, the browser has to download HTML and JavaScript files and execute the framework before it could display the page. In the meanwhile, the user has to deal with a blank page, which is a bad indicator for user experience.

Although the final page will take the same amount of time to load and user only gets a glimpse of the page initially, server side rendering has the psychological edge from a user’s point of view. A semi-loaded page will look more compelling than a blank page to users.

  • Search Engine Optimization

JavaScript front-ends are incomprehensible to Search engines crawlers. The crawler will return a blank page on encountering such a page on its journey to crawl new pages. Google, of course, will not index a page, which is blank to its crawler.

SEO of React Apps

Lack of search engine optimization is a huge drawback of client side rendering. server side rendering of JavaScript returns a pre-rendered HTML page for ready-display to the browser. The crawlers can crawl HTML as would any other web application. For businesses invested into digital marketing and SEO, server side rendering makes a lot more sense than client-side rendering.

Server Side Rendering with TOPS Infosolutions

In fall 2015, our React developers were attempting to rework an application originally built in AngularJS. We invested many hours of efforts to heighten the performance but the client insisted that the application was doing more or less the same in AngularJS. React was still a newer technology and we were quite skeptical about how server side rendering will work out. A few migrations and some changes in business logic and we were ready for the demo. The application out performed the client expectations. He insisted on going SSR way for all his future application.

Server Side Rendering is a luxury you can deliver in the form of a refined experience to your users. After all, the cut-throat competition doesn’t allow for anything that is any short of best.

Contact TOPS for react development

FAQs

  • Can server side rendering help boost user engagement?
    Server side rendering or SSR can help enhance user engagement by doing away with empty page problems that may occur in client side rendering or CSR. As a result, this can help bring down the website’s bounce rate.
  • Does SSR improve page loading speed?
    As compared to CSR, server side rendering creates a semi-loaded page instead of a blank page in the CSR, which helps to enhance the user experience.
  • Does SSR provide better SEO possibilities than CSR?
    Lack of search engine optimization is a major drawback of client side rendering. This is why for businesses invested in search engine optimization and digital marketing, server side rendering makes more sense than client-side rendering.
  • Is SSR better than CSR?
    The experienced experts and developers at TOPS Infosolutions know that SSR helps to boost user experience and is a better option to keep them engaged. It also offers consistent SEO performance, which is why SSR seems to be a better choice as compared to CSR.

Why Choose React for Front-End Development?

React for Front-end development

With more than 1,300 developers and over 94,000 sites utilizing ReactJS, it won’t be an overstatement to call React the future of front-end development. After all, Fortune-500 companies like Facebook, PayPal, Uber, Instagram, and Airbnb utilize this JavaScript based UI library for a major part of their applications’ front-end development on web as well as mobile.

Before React arrived

When React came, AngularJS was the only major contender in the JS framework space. While Angular was most complete framework (it still is), it was a nightmare for developers. They had to do a lot of coding, and with a steep learning curve even for seasoned JavaScript developers, AngularJS was never the most desirable way to build JS applications. It has too many functionalities that most developers need.

React isn’t a framework

react is not a framework

Then came ReactJS and it revolutionized the way web applications are developed. However, React isn’t a MVC framework unlike Angular; it is a ‘view’ only library. That is, ReactJS doesn’t include state managers, routers and API managers in the core library. It may look like a limitation to you but for React developers, this is simplicity at its best because front-end development in React centers around the React ecosystem, not just the core element, which at the end of the day removes unnecessary complicacies.

React Ecosystem

React Ecosystem

Technically speaking, developers can expand what core React library can do by means of additional libraries. React together with those libraries form the React ecosystem. For example, there is Redux for state management, React Router for routing, and Axios to facilitate API interaction. Tens of thousands of such libraries are part React Ecosystem. Unlike Angular, templates aren’t part of React ecosystem. React doesn’t use templates rather…

React uses Components

This may turn out quite a no-brainer for most web developers and those looking to develop React applications. Just like not being an MVC framework has its advantages, the depreciation of templates also does. If you look closer, HTML templates restrict the set of abstraction you can include in your UIs.

There is a reason React is called the best library to build UI. The way it approaches building user interfaces is unique yet approachable. ReactJS breaks UI into independent, reusable pieces, and isolated components. This is how you define a component ‘Welcome’ in ES6.

react components

Moreover, you don’t have to write down every component while building an application in React. There are many component libraries available in the React ecosystem: React Material-UI, React-Bootstrap, React Belle, are some of them.

All these awesome UI tricks may make you think otherwise; don’t they bog down performance of the resulting application due to extensive DOM manipulation we are subjecting it to? That’s a valid argument but did I mention Virtual DOM?

Note: DOM elements form the part of an application the user sees.

The Virtual DOM

Extensive DOM manipulation is a known bottleneck to a web app’s performance regardless how fast the client platform and the JavaScript engine is.

If you look at the image above, DOM has tree like structure and simple change on the top level may take some time to reflect on the lower levels. This may delay UI responses and ultimately hurdles with the user experience.

Virtual DOM

Fortunately, React solves the problem with a layer of Virtual DOM between the user layer and actual DOM. Virtual DOM is a virtual representation of the DOM,and it stays on the memory rather than user screen. So the question arises, what goes on the user screen then?

Note: Virtual DOM is conspicuous by its absence on Angular

An algorithm keeps a track of the changes made on the virtual DOM and determines which changes must make it to the real DOM and, thus, user screen. Let’s say the application contains a few React components with their own logic and rendering. Since React is fundamentally JavaScript, a single change in one of the components will manipulate the entire DOM, which if happens frequently may affect the performance as I described above.

This is where Virtual DOM comes in. It absorbs any change to the DOM and keeps it to the memory. The algorithm then detects on which component the change was made and updates that part of the DOM. This change will reflect on the user screen without disturbing the other components.

In ReactJS applications, only the component changes not the entire page to a user response. That means, the page URL remains the same regardless of user interaction. So how can you make the page discoverable to search engines?

react native app development

Server Side Rendering

Server-side rendering your React app to output HTML content

React needs Server-side rendering to deliver an HTML response when a user or crawler hits a page URL. We handle the requests on the client side and render the React components on the server.

Server Side Rendering

A major problem is Google crawlers can’t yet render JavaScript. That is the crawler will return a blank page upon rendering a block of JavaScript code. To make React pages understandable to Google Crawlers, we need server-side rendering for React.

With server-side rendering, React will render JavaScript pages with same consistency they do HTML and XML pages. Better SEO will ensure your web application is more discoverable by search engine and return a better value.

JSX and Final Thoughts

The idea of mixing JavaScript with HTML may sound intimidating at first. Purist web developers even feel guilty on mixing those two.

jsx

JSX is actually a syntax extension to JavaScript, which is like template languages except it comes with the full power of JavaScript. React, as I described in the section above, separates concerns with components rather than putting markup and logic in separate files. Of course, React doesn’t require JSX but it acts like a visual aid when working with user interfaces in JavaScript that no React developer tends to ignore. It also allows makes debugging easier with useful error codes and warnings.

Frankly speaking, whether JSX is an initiative in good direction is matter of great debate. While it makes coding way simpler when compared with Angular, people debate that it violates the fundamental rule of programming, separation of concerns, which is a bad coding practice in the first place.

Hire React Developers

Quick Inquiry

Quick Inquiry