Book Image

Beginning Server-Side Application Development with Angular

By : Bram Borggreve
Book Image

Beginning Server-Side Application Development with Angular

By: Bram Borggreve

Overview of this book

Equip yourself with the skills required to create modern, progressive web applications that load quickly and efficiently. This fast-paced guide to server-side Angular leads you through an example application that uses Angular Universal to render application pages on the server, rather than the client. You'll learn how to serve your users views that load instantly, while reaping all the SEO benefits of improved page indexing. With differences of just 200 milliseconds in performance having a measurable impact on your users, it's more important than ever to get server-side right.
Table of Contents (10 chapters)

Generating the Server App


Since Angular CLI version 1.6, there has been a generator for adding support for Angular Universal. It does this by adding a second app to the Angular CLI config, .angular-cli.json.

We will refer to this new app as our server app, and the one we worked with in the previous lesson will be called our browser app.

So, what are the differences between the browser and server apps?

  • Both load another platform which behaves differently.

  • The browser app uses code splitting, which builds the app in various smaller files. This improves load times in the browser. The server builds the app without code splitting as there are no benefits to do this on the server.

  • The browser app loads a greater number of polyfills. These are small JavaScript libraries that add functionality to the browser, if the browser does not support them yet. This is not needed for the server.

Let's explore in some more detail what happens when we run the generator:

Running this generator will change a few things...