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

No comments:

Post a Comment

Is Google Gemini AI Coming to Outsmart ChatGPT?

  AI & Machine Learning Gizel Gomes ,  March 20, 2024  |   4 min read As the GenAI race heats up, so does the quest for most human-like,...