Just-in-Time (JiT) vs Ahead-of-Time (AoT) compilation in Angular
JIT (Just-in-Time Compilation)
Just-in-Time (JIT) is a type of compilation that compiles your app in the browser at runtime.
ng build
ng serve
Benefits of JIT:
- It Compiled the code in the browser.
- Each file of the application is compiled separately.
- This is suitable for local development.
- If there is any binding error then Template binding errors are shown at the time of application is rendered.
AOT (Ahead-of-Time Compilation)
Ahead-of-Time (AOT) is a type of compilation that compiles your app at build time.
ng build --aot
ng serve --aot
Benefits of AOT:
- Faster startup as Parsing and Compilation doesn’t happen in the Browser.
- Templates gets checked during development(which means all the errors which we see in the javascript console in the running apps otherwise will then be thrown in our build process).
- Smaller File Size as unused Features can be stripped out and the Compiler itself isn’t shipped.