Angular: JIT and AOT

With Angular 1 and early stages of Angular 2, JIT (Just In Time) has been the way of compiling Angular code. With this approach, the compiler performs a lot of work to analyze the components in the application at runtime (generating code in memory). Since this is just stored in memory, when the page is refreshed, all of that work is lost. So, the JIT compiler does the work all over again. Doesn’t sound that efficient, huh?

What’s “AOT” ? It stands for Ahead Of Time.

With an AOT compiling approach, Angular apps can be built to not require much of the compiler, change detection, or dependency injection systems at runtime. This leads to a significantly smaller application payload. And since the component factories are generated at build time, Angular can skip the compilation and move straight to creating views at runtime.

Considering these two approaches to compilation, we can see how AOT provides significant improvements to load time, as the majority of the compilation work is already completed before the code gets sent to the browser and the AOT compiled code yields less code that we need to send to the browser.