Performance: Tree shaking and dead code removal
This affects the bundle size and initial load speed by removing unused code from the final app package.
Jump into concepts and practice - no test required
import { ComponentA } from 'library'; @Component({ ... }) export class MyComponent { ... }
import { ComponentA, ComponentB, ComponentC } from 'library'; // Using only ComponentA in the app @Component({ ... }) export class MyComponent { ... }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Import entire library | No direct impact | No direct impact | Larger JS bundle delays paint | [X] Bad |
| Import only used modules | No direct impact | No direct impact | Smaller JS bundle speeds paint | [OK] Good |
unusedMethod() is never called anywhere?export class DataService {
fetchData() { return 'data'; }
unusedMethod() { return 'not used'; }
}