Angular Ivy: The Tree-Shakable Compiler

Angular's Ivy engine compiles components like separate puzzle pieces, making apps smaller and faster. This enables effective tree-shaking for smaller bundles and faster rebuilds.
WHY IT EXISTS: Angular's previous compiler, View Engine, produced large, complex JavaScript files that were difficult for bundlers to optimize. This resulted in larger application sizes and slower compilation cycles. Ivy was created to solve these problems by generating code that is smaller, more efficient, and easier to tree-shake.
THE MENTAL MODEL: Think of Ivy as a "local" compiler that treats each component like a self-contained puzzle piece. It compiles each component in isolation, generating a set of instructions for how to create and update its part of the DOM, without needing global knowledge of the entire application.
HOW IT WORKS: Ivy transforms your HTML templates into a series of plain JavaScript instructions attached directly to your component class. For instance, a template like Hello becomes a sequence of function calls like ɵɵelementStart('p'), ɵɵtext('Hello'), and ɵɵelementEnd(). Because these are just functions, any unused Angular features referenced by these instructions can be "tree-shaken" (removed) by a bundler during the build process, dramatically shrinking the final application size.
WHEN TO USE IT: As the default and only compilation engine in Angular since version 9, you are always using Ivy. Its benefits are most apparent in large-scale applications where bundle size is a primary concern and during development, where its faster incremental compilation speeds up rebuilds and improves developer workflow.
WHEN NOT TO USE IT: You don't have an option to disable Ivy in modern Angular. The main friction point is not a choice to avoid it, but rather a compatibility issue. You may encounter problems when trying to integrate very old, unmaintained third-party libraries that were compiled with the legacy View Engine and have not been updated to the Ivy-compatible Angular Package Format.
ONE CANONICAL EXAMPLE: Consider a simple component template: <h1>{{ message }}</h1>. With View Engine, this would generate a separate, complex ngfactory.js file. With Ivy, the compiled output is a static ɵcmp property on the component class itself. This property contains an instruction set like ɵɵelementStart(0, "h1"), ɵɵtext(1), ɵɵelementEnd(), and a binding instruction ɵɵtextInterpolate(ctx.message). This instruction-based approach is far more transparent and easier for build tools to optimize.
Read the original → angular.dev
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.