Friday, November 2, 2018

Angular AOT Compiler

AOT stands for Ahead of Time. AOT compiler helps pre-compile Angular applications so that they can be rendered faster in the browser.

We know that Angular applications consists of components and service classes written in TypeScript and HTML templates. Browsers cannot understand TypeScript hence they need to be compiled into JavaScript.

Angular provides 2 types of compilers for this compiling process.



1. Just-In-Time (JIT) compiler.
2. Ahead-of-Time (AOT) compiler.


With Just-In-Tile compiler the compilation happens at runtime in the browser. With Ahead-of-Time compiler the compilation happens at build time.

Just-In-Compiler is the default Angular compiler used during development phase, the following commands invoke the JIT compiler.

ng build
ng server


The use the Ahead-of-Time AOT compiler we need to use the –aot switch as follows.

ng build --aot
ng server –aot


Production builds with the -–prod switch will use the AOT compiler by default

ng build --prod

Advantage of using the AOT Compiler is that it compiles the application at build time to provide faster rendering in the browser. With AOT compiler all the classes and templates are compiled and bundled at build time so that the browser need not compile the classes and templates at run-time it just has to download and render the application.


Search Flipkart Products:
Flipkart.com

No comments: