Performance: Why i18n matters
MEDIUM IMPACT
Internationalization (i18n) affects page load speed and rendering by managing language resources efficiently and avoiding unnecessary content duplication.
import { Component } from '@angular/core'; @Component({ selector: 'app-root', template: `<div>{{ 'HELLO' | translate }}</div>` }) export class AppComponent { // Lazy loads language files only when needed constructor() { } }
import { Component } from '@angular/core'; @Component({ selector: 'app-root', template: `<div>{{ 'HELLO' | translate }}</div>` }) export class AppComponent { // Loads all language files eagerly constructor() { } }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Eager loading all languages | Low | Multiple on language switch | High due to layout shifts | [X] Bad |
| Lazy loading languages on demand | Low | Single or none | Low with stable layout | [OK] Good |