What is AOT Compilation in Angularjs 2

AOT (Ahead of Time compilation) is used to compiles the angular components and templates to native JavaScript and HTML during the build time instead of run-time.
The compiled HTML and JavaScript are deployed to the web server so that the compilation and render time can be saved by the browser. So It is the biggest advantage of AOT to improve the performance of applications.

Advantages:

  • Smaller Angular framework download size:  The Angular 2 app is already compiled so it is faster.
  • Faster Rendering: The browser downloads a pre-compiled version of the application. So the browser loads already executable code and without waiting, it can be render immediately.
  • Fewer asynchronous requests: It is supporting to the lazy loading. Actually, lazy loading is great concepts for sending HTTP request to the server. It is minimise the multiple requests for each associated html and css, there is a separate request goes to the server.
  • Detect template errors earlier: The compilation happens before and most of the errors can be detected at the compile time and this process providing us a better application stability.
  • Better security: It compiles components and HTML templates into JavaScript files long before they are served to the client. With no templates to read and no risky client-side HTML or JavaScript evaluation, there are fewer opportunities for injection attacks.

Disadvantages:

  • AOT only works only with HTML and CSS and not for other file types. If required other file types that time we will need to follow the previous build step.
  • We need to maintain AOT version of bootstrap file.
  • We need to clean-up step before compiling.
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkedin
Share On Pinterest

Be the first to comment

Leave a Reply

Your email address will not be published.

*


*