While reading Angular2 doc, I came to know that:
Angular offers two ways to compile your application:
What are the differences and benefits?
In production, you HAVE to use AOT. JIT makes your server send compiler code as well to the browser and let the client compile your code. This adds overhead at the request and bootstrap time. So, in order to shrink your bundle size and improve performance of your application, you have to use AOT.
Also, you should always use AOT if you can even in development environment.
From angular-cli 1.5, you can use --aot
option with ng serve
. This will provide you an environment like your production, so you will see how your app will behave in production beforehand. Also, since it compiles your code on your server, you catch errors way before you run it on a browser.
In upcoming versions of Angular-Cli, AOT will be the default option on ng serve
.