angular-performance

Performance optimization with OnPush, bundle analysis, and change detection strategies

View on GitHub
Author Ihsan - Full-Stack Developer & AI Strategist
Namespace @EhssanAtassi/angular-master-marketplace
Category performance
Version 1.0.0
Stars 0
Downloads 4
self.md verified
Table 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

  1. Bundle Analysis
  2. Lazy Loading Strategies
  3. Tree Shaking
  4. Code Splitting
  5. Library Optimization
  6. Build Configuration
  7. Image Optimization
  8. 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:

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:

…(truncated)

Source

View on GitHub

Tags: performance angularperformanceoptimizationonpushbundle