Sunday, April 2, 2023

Angular Performance Optimization Techniques

 


How to solve this problem?

Optimization Techniques

1: OnPush change detection strategy

@Component({
selector: ‘child-component',
changeDetection: ChangeDetectionStrategy.OnPush,
template: `...`
})

2: Detach Change Detection/NgZone

class TestComponent {
constructor(private changeDetectorRef: ChangeDetectorRef) {
changeDetectorRef.detach()
}
clickHandler() {
chnageDetectorRef.detectChnages()
}
}

3: Using Pure Pipes

4: AOT Compilation

5: Lazy Loading

export const routes = [
…homeRoutes,
{
path: “users”,
loadChildren: “./users/users.module#UserModule”,
}
];

6: Trackby

7: Web Workers

8: Preloading Modules

9: Resolve Guards

10: Unsubscribe from Observables

Key phrase extraction with Azure Cognitive Services

Don't have Azure?   Grab a free subscription . I recently took a look at Text Analysis that was introduced with Cognitive Services and i...