Angular code is compiled to serve in the browser, when any request comes from the server.
In angular we have two options to choose the compilation process one is JIT another is AOT.
JIT and AOT have their own pros and cons, one is post compilation another is pre compilation.
Just-in-Time (JiT) compiler:
JIT complies the angular template and Typescript code to the browser understanding language at run time.
That's why it called just in time, means whenever needed then only it compiles the code in browser understanding language.
Whenever a request comes from browser, server sends the build code to browser, then JIT compiler compiles that code there on the browser and then renders.
Ahead-of-Time (AOT) compiler:
AOT compiles the angular template and Typescript code to the browser understanding language at the build time.
That's why it called ahead of time, means it is pre complied and kept on the server.
Whenever a request comes from browser, it only have to render the pre compiled code.
ng build --aot
ng serve --aot
It reduced the build size up-to one third of the normal build size.
It saves the JIT compilation time, which saves up-to 60% of the rendering time.