Performance: Why SSR matters for Angular
HIGH IMPACT
Server-Side Rendering (SSR) affects how fast the main content appears on screen and improves user interaction speed by pre-rendering HTML on the server.
import { renderModule } from '@angular/platform-server'; const html = await renderModule(AppServerModule, { document: '<app-root></app-root>', url: '/' });
bootstrapApplication(AppComponent); // Client-side only rendering| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Client-side only rendering | Delayed DOM creation until JS runs | Multiple reflows as JS builds DOM | High paint cost due to late content | [X] Bad |
| Server-Side Rendering (SSR) | DOM created from server HTML immediately | Single reflow on initial load | Low paint cost, fast content display | [OK] Good |