1.

Explain AOT in Angular?

Answer»

An Angular application consists mainly of components and their HTML templates. Because the components and templates provided by Angular cannot be understood by the browser directly, Angular applications require a compilation process before they can run in a browser.

The Angular Ahead-of-Time (AOT) compiler converts your Angular HTML and TypeScript code into EFFICIENT JavaScript code during the build PHASE before the browser downloads and runs that code. Compiling your application during the build process provides a faster rendering in the +browser.

  • Faster rendering - With AOT, since the application code is already compiled, the browser downloads a pre-compiled version of the application and therefore can load the app immediately without having to recompile the whole app.
  • Fewer asynchronous requests - The inlining of the external HTML templates and CSS style sheets eliminate separate ajax requests for those source files.
  • Smaller Angular FRAMEWORK download size - Since the application code is already compiled, there's no need to download the Angular compiler along with the code. The compiler is roughly half of Angular itself, so omitting it dramatically reduces the application payload.
  • Detect template errors earlier - The AOT compiler detects and reports template binding errors during the build step before users can see them. Thus it saves a lot of error finding and debugging time.
  • Better security - AOT compiled HTML templates and components 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.


Discussion

No Comment Found