0

I know that "ahead of time compilation" provides compilation at the build time. There are also bunch of other advantages of --aot such as

  • the application is pre-compiled so there is no such a wait template

  • binding errors will be known at build time etc..

However, there is also an option to set --aot to false (for the prod build as well). Why do we ever need to set --aot to false? In other word, what kind of advantage does --jit provides? I just want to understand if there is any disadvantage of using --aot over --jit because otherwise, it sounds like I should always use --aot even in dev build. And if there is no trade-off by using --aot, then why it is not set as default for the ng build and ng serve ?

curiousBoy
  • 6,334
  • 5
  • 48
  • 56
  • 1
    Historically, AOT is just much slower and therefore JIT was the preferred way for local development. With Angular 9 and Ivy, AOT is the default even for development builds, though. – Ingo Bürk Feb 09 '20 at 15:42

2 Answers2

0

As @Ingo Burk mentioned in the comment, I end up with same findings so I wanted to post it as an answer.

Also other interesting thing I found out was,

However In version 5 and later, the compiler automatically performs this rewriting while emitting the .js file

curiousBoy
  • 6,334
  • 5
  • 48
  • 56
0

AOT is good in terms of performance as code is complied much before loading to the browser as in JIT. It is now byDefault available after Angular 8. @CuriousBOy and @Ingo mention a few use cases where Jit is preferred.

One More use case I want to add for dynamic component and module rendering.

If you need to create the component at runtime and want to render it you might need JIT in Browser, because AOT will not be able to compile the code as the Dynamic component and Dynamic module are not available at the build time.

Amit Singh
  • 279
  • 2
  • 7