Build & Optimization
Production builds, AOT compilation, tree shaking, lazy loading, bundle optimization, source maps, budgets
1What is AOT compilation in Angular?
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.
2What is the main advantage of AOT over JIT compilation?
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.
3How to enable AOT compilation in an ng build command?
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.
Which configuration in angular.json enables optimizations for a production build?
What is tree shaking in Angular?
+17 interview questions
Other Angular interview topics
TypeScript Basics
TypeScript Advanced
Angular Fundamentals
Components & Lifecycle
Services & Dependency Injection
Angular Modules Organization
Angular CLI
Directives & Pipes
Routing & Navigation
Reactive Forms
Template-driven Forms
RxJS Fundamentals
RxJS Operators
HttpClient & API Calls
Basic State Management
Change Detection
Angular Signals
Standalone Components
Angular Unit Testing
End-to-End Testing
NgRx Fundamentals
NgRx Advanced
Angular Architecture
Performance Optimization
Security & Best Practices
Advanced RxJS Patterns
Angular Universal & SSR
Angular Micro-frontends
Master Angular for your next interview
Access all questions, flashcards, technical tests, code review exercises and interview simulators.
Start for free