Performance: Why standalone components matter
MEDIUM IMPACT
Standalone components reduce bundle size and speed up initial page load by avoiding large module dependencies.
import { Component } from '@angular/core'; @Component({ standalone: true, selector: 'app-my', template: `<p>Standalone works!</p>`, imports: [] }) export class MyComponent {}
import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { MyComponent } from './my.component'; @NgModule({ declarations: [MyComponent], imports: [CommonModule], exports: [MyComponent] }) export class MyModule {}
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| NgModule-based component | Moderate (due to module wrappers) | 1-2 reflows per module load | Medium paint cost | [X] Bad |
| Standalone component | Minimal (direct component) | Single reflow | Low paint cost | [OK] Good |