in Technology by
What is AOT compilation? What are the advantages of AOT?

1 Answer

0 votes
by

Every Angular application consists of components and templates which the browser cannot understand. Therefore, all the Angular applications need to be compiled first before running inside the browser.

Angular provides two types of compilation:

  • JIT(Just-in-Time) compilation
  • AOT(Ahead-of-Time) compilationEvery Angular application consists of components and templates which the browser cannot understand. Therefore, all the Angular applications need to be compiled first before running inside the browser.


    Angular provides two types of compilation:

  • JIT(Just-in-Time) compilation
  • AOT(Ahead-of-Time) compilation
  •  
image


In JIT compilation, the application compiles inside the browser during runtime.
Whereas in the AOT compilation, the application compiles during the build time.

The advantages of using AOT compilation are:

 

  • Since the application compiles before running inside the browser, the browser loads the executable code and renders the application immediately, which leads to faster rendering.
  • In AOT compilation, the compiler sends the external HTML and CSS files along with the application, eliminating separate AJAX requests for those source files, which leads to fewer ajax requests.
  • Developers can detect and handle errors during the building phase, which helps in minimizing errors.
  • The AOT compiler adds HTML and templates into the JS files before they run inside the browser. Due to this, there are no extra HTML files to be read, which provide better security to the application.
  •  

By default, angular builds and serves the application using JIT compiler:

ng build
ng serve

For using AOT compiler following changes should be made:

ng build --aot
ng serve --aot

Related questions

0 votes
    What are the benefits of Explicit Compilation (AOT)?...
asked Feb 16, 2023 in Technology by JackTerrance
0 votes
    Why applications compiled with AOT (Ahead of compilation) launch faster?...
asked Jun 28, 2021 in Technology by JackTerrance
0 votes
    What are the stages in the compilation process? Select one: a. Feasibility study system design and testing b. ... of the above? Select the correct answer from above options...
asked Nov 27, 2021 in Education by JackTerrance
0 votes
    I am following simple examples to build up my understanding on private static members. However, I am getting ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    During a long compilation with Visual Studio 2005 (version 8.0.50727.762), I sometimes get the following ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    During a long compilation with Visual Studio 2005 (version 8.0.50727.762), I sometimes get the following ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 16, 2022 in Education by JackTerrance
0 votes
    Write error message given by C compiler during compilation if we use %d to print float variable Select the correct answer from above options...
asked Nov 27, 2021 in Education by JackTerrance
0 votes
    De-compilation is not done for _______________ (a) Recovery of lost source code (b) Migration of assembly ... for-Cyber Security:,Cyber Security-Jobs:,Cyber Security Applications...
asked Oct 31, 2021 in Education by JackTerrance
0 votes
    linking assembling preprocessing compiling Select the correct answer from above options Java questions and answers, Java ... and answers pdf, java interview questions for beginners...
asked Oct 26, 2021 in Education by JackTerrance
0 votes
    How can we identify whether a compilation unit is class or interface from a .class file? (a) Java ... programming questions and answers pdf, java interview questions for beginners...
asked Oct 26, 2021 in Education by JackTerrance
0 votes
    What are the advantages of digital circuits? a) Less noise b) Less interference c) More flexible d) All of the mentioned...
asked Dec 29, 2022 in Technology by JackTerrance
0 votes
    What is the user stories in Scrum? What are the advantages of using them?...
asked Aug 19, 2021 in Technology by JackTerrance
0 votes
    What are the advantages of using a VPN?...
asked Aug 14, 2021 in Technology by JackTerrance
0 votes
    What is Scrum? what are advantages....
asked Jul 18, 2021 in Technology by JackTerrance
...