angular-performance
Performance optimization with OnPush, bundle analysis, and change detection strategies
View on GitHubTable of content
Performance optimization with OnPush, bundle analysis, and change detection strategies
Installation
npx claude-plugins install @EhssanAtassi/angular-master-marketplace/angular-performance
Contents
Folders: agents, commands, skills
Included Skills
This plugin includes 2 skill definitions:
bundle-optimization
View skill definition
Angular Bundle Optimization
Complete guide to reducing Angular bundle sizes through code splitting, tree shaking, and lazy loading.
Table of Contents
- Bundle Analysis
- Lazy Loading Strategies
- Tree Shaking
- Code Splitting
- Library Optimization
- Build Configuration
- Image Optimization
- Caching Strategies
Lazy Loading Strategies
Route-Based Lazy Loading
// app.routes.ts
export const routes: Routes = [
{
path: 'dashboard',
loadComponent: () => import('./dashboard/dashboard.component')
.then(m => m.DashboardComponent)
},
{
path: 'users',
loadChildren: () => import('./users/users.routes')
.then(m => m.USERS_ROUTES)
},
{
path: 'admin',
loadChildren: () => import('./admin/admin.routes')
.then(m => m.ADMIN_ROUTES),
canActivate: [AuthGuard] // Only loads if authorized
}
];
Impact: Main bundle reduced by 40-60%
Component Lazy Loading
// Before: Imported at module level
import { HeavyChartComponent } from './chart/heavy-chart.component';
@Component({
template: `
<app-heavy-chart *ngIf="showChart" [data]="chartData" />
`
})
export class DashboardComponent {
showChart = false;
}
// After: Dynamic import
@Component({
template: `
<ng-container *ngIf="chartComponent
...(truncated)
</details>
### change-detection
<details>
<summary>View skill definition</summary>
# Angular Change Detection Optimization
Comprehensive guide to Angular change detection, OnPush strategy, Signals, and Zone.js optimization.
## Table of Contents
1. [How Change Detection Works](#how-change-detection-works)
2. [Default vs OnPush](#default-vs-onpush)
3. [OnPush Strategy Patterns](#onpush-strategy-patterns)
4. [Angular Signals](#angular-signals)
5. [Zone.js Optimization](#zonejs-optimization)
6. [Manual Change Detection](#manual-change-detection)
7. [Common Pitfalls](#common-pitfalls)
8. [Performance Monitoring](#performance-monitoring)
## Default vs OnPush
### Default Strategy
```typescript
@Component({
selector: 'app-user-list',
template: `
<div>{{ currentTime }}</div>
<button (click)="refresh()">Refresh</button>
`
})
export class UserListComponent {
currentTime = new Date().toLocaleTimeString();
refresh() {
this.currentTime = new Date().toLocaleTimeString();
}
}
Behavior:
- Checks on every CD cycle
- Even if data didn’t change
- Performance cost: High (scales with components)
OnPush Strategy
@Component({
selector: 'app-user-list',
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<div>{{ currentTime }}</div>
<button (click)="refresh()">Refresh</button>
`
})
export class UserListComponent {
currentTime = new Date().toLocaleTimeString();
refresh() {
this.currentTime = new Date().toLocaleTimeString();
}
}
Behavior:
- Only checks when:
- **@In
…(truncated)