Performance: GET requests
MEDIUM IMPACT
GET requests impact page load speed and interaction responsiveness by controlling how fast data is fetched and rendered.
ngOnInit() {
forkJoin({
data: this.http.get('/api/data'),
extra: this.http.get('/api/extra')
}).subscribe(results => {
this.data = results.data;
this.extra = results.extra;
});
}ngOnInit() {
this.http.get('/api/data').subscribe(data => {
this.data = data;
});
this.http.get('/api/extra').subscribe(extra => {
this.extra = extra;
});
}| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Multiple separate GET requests | Multiple DOM updates | Multiple reflows triggered | Higher paint cost due to incremental updates | [X] Bad |
| Batched GET requests with forkJoin | Single DOM update | Single reflow | Lower paint cost with consolidated update | [OK] Good |