Angular

Build & Optimization

Production builds, AOT compilation, tree shaking, lazy loading, bundle optimization, source maps, budgets

20 interview questionsยท
Mid-Level
1

What is AOT compilation in Angular?

Answer

AOT (Ahead-of-Time) compilation transforms Angular code and templates into optimized JavaScript during the build phase, before deployment. This reduces bundle size as the Angular compiler is not included, improves loading performance, and detects template errors earlier. Since Angular 9, AOT is enabled by default for all builds.

2

What is the main advantage of AOT over JIT compilation?

Answer

AOT produces smaller bundles because the Angular compiler (about 1MB) is excluded from the final bundle, unlike JIT which requires the compiler in the browser. AOT also improves loading time by eliminating client-side compilation, detects template errors earlier, and improves security by pre-compiling templates.

3

How to enable AOT compilation in an ng build command?

Answer

Since Angular 9, AOT is the default compilation for all environments. For a production build, using ng build --configuration production automatically enables AOT. The --aot flag exists but is redundant as AOT is now always active unless explicitly configured otherwise in angular.json.

4

Which configuration in angular.json enables optimizations for a production build?

5

What is tree shaking in Angular?

+17 interview questions

Master Angular for your next interview

Access all questions, flashcards, technical tests, code review exercises and interview simulators.

Start for free