To understand this, you must first understand that browsers always compile Javascript files to a binary they can understand.
When we talk about compiling our Angular project, we do not talk about this compilation. This is done by the browser (Chrome, Firefox, etc.) with respect to its binaries.
Now, with Angular (not AngularJS), the vast majority of the development is done in TypeScript. This code in TypeScript must be compiled to Javascript at some time. We refer to that compilation.
As it says the documentation , Angular offers two ways to compile the application:
JIT (Just in time), which compiles the application in the browser
at the time of execution. JIT compilation is the default when you run the single build or build and serve commands:
ng build
ng serve
AOT (Before the moment), which compiles the application at the time of
construction (compilation). To compile AOT, add the ---aot
suffix to the build commands:
ng build --aot
ng serve --aot
Note that when you run the commands with --prod
compiles with AOT by default.
All this means that JIT and AOT are just the moments when you are going to compile TypeScript to Javascript. But there are also advantages and disadvantages.
When you compile JIT in development you save the time of compiling all that TypeScript and leave it at the moment of execution. But you have to take the Angular compiler that weighs pretty. It's better to make quick compilations in development.
When you compile in AOT your compilation time will take a long time, but you save the compiler space. So it's better to produce the production code.