Directory Image
This website uses cookies to improve user experience. By using our website you consent to all cookies in accordance with our Privacy Policy.

Server Side Rendering in Angular – Angular Universal

Author: Anuj Singh
by Anuj Singh
Posted: Apr 13, 2018

What is Server Side Rendering?

Server Side Rendering in Angular is rendering the initial view from server side later on everything will be handled by the Browser. In, this blog we will try to implement SSR in Angularjs.

Regular Angular Application

A normal Angular application executes in the browser. On User’s demand, It renders pages in the DOM. Initially, Browser receives empty index.html(common developer love to name it as). similar to code mentioned below.

If you observe we got absolutely no content initially. Now, the browser will download all JS, CSS files and it will generate DOM accordingly. Having no content on the page means your page is irrelevant for any searching operation that user google. wow, we got one limitation of the traditional angular application.

Angular Universal OR Server-Side Rendering

Angular Universal generates static application pages on the server through a process called server-side rendering (SSR).

Generally, It can generate prerendered HTML pages which will be sent to the browser on user’s request. It means User will always get something on an inital load of the page. Which is good for our SEO. After the initial Load Browser switch off the SSR mode as all files are downloaded. The client has everything to deal with.

Here on, Let me refer Server Side Rendering as Universal Angular.

Why Universal?
  1. Better SEO
  2. Improved Performance on mobile devices.
  3. Loading pages quickly

Better SEO: Any Search Engine like Google, Bing does not read javascript. It gets an idea of what your pages are suggesting based on HTML that rendered. Although, how interactive your page is OR how efficient JS code(why are we talking about js code if web crawlers do not read them? oops, maybe I am just convincing you), Your page will never be highly indexed by them.

Angular Universal can generate a static version of your app that is easily searchable, linkable, and navigable without JavaScript. It also makes a site preview available since each URL returns a fully-rendered page.

Improved Performance on mobile devices: some small devices are so poor to Javascript, that initial loading is tough to handle. If they get prerendered markup, I mean HTML. User Experience will be better.

Loading pages quickly: 53% of the user leaves the website if it takes initial loading time greater than 3 sec. To keep the user engaged you need to load your initial view quicker. When user sees pages loaded he gets busy in looking into your app. Meanwhile, your all scripts get downloaded the and browser gets everything that is needed. Hereafter everything goes like a tracer bullet.

How It Works:

To implement Universal App, you need to install platform-server package. what does this package contain? This package has a server implementation of DOM, XMLHttpRequest, and some low-level features so that we don’t need the browser to generate initial view.

Looking for AngularJS Development Company,

Hire dedicated angularjs developers

About the Author

Inwizards Inc is a custom Web And App Development Company India & usa, providing all web & Mobile App solution to make your web presence unique worldwide

Rate this Article
Leave a Comment
Author Thumbnail
I Agree:
Comment 
Pictures
Author: Anuj Singh

Anuj Singh

Member since: Sep 06, 2017
Published articles: 14

Related Articles