Reputation: 15303
I my angular app, i have no.of modules. when i change something with html or css it take time to re-compile. so i decided to start with ng serve --aot=true
but I find it take more time to run the app compare to without any flag as ng serve
. But what is wrong here or what is the purpose of ng serve --aot=true
then?
any one help me to understand the ng serve --aot=true
flag.
Upvotes: 1
Views: 1291
Reputation: 1160
Angular offers 2 ways to bind your application:
Just-in-Time (JIT), which compiles your app in the browser at runtime. (when you run ng serve
)
Ahead-of-Time (AOT), which compiles your app at build time. (when you run ng serve --aot=true
)
The ng build command with the --prod meta-flag (ng build --prod) compiles with AOT by default.
The Angular Ahead-of-Time (AOT) compiler converts your Angular HTML and TypeScript code into efficient JavaScript code during the build phase before the browser downloads and runs that code. Compiling your application during the build process provides a faster rendering in the browser.
As JIT compiles your app at runtime, it can optimize the compilation and only build necessary code. So in development mode, it's common to use JIT to save the time of a full build. The compilation time will be faster using JIT.
AOT optimizes the running speed but the compilation time is longer, thats why it's common to use it in production. AOT will also optimize the size of your application as all files will be compiled before running it.
Upvotes: 2