Built-In Font Optimization: Improve Angular Performance & Core Web Vitals
- Lenguaje dominante
- TypeScript
- Estrellas
- 27k
- Forks
- 11.8k
- Merge medio
- 14 h 23 min
- PR fusionados (30 d)
- 162
Descripción
### Which @angular/* package(s) are relevant/related to the feature request?
@angular/core and @angular/cli
### Problems :
- Using custom fonts from **Google Fonts** can significantly impact FCP, LCP and initial load performance in Angular applications.
- Downloading fonts from Google servers adds **extra HTTP requests** and **latency**, slowing down initial paint times.
- The **font swapping** has the potential to cause layout shifts and so impact Cumulative Layout Shift (CLS).
### Proposed Solution :
- Introduce a **built-in** **mechanism** in Angular to **automatically downloads fonts** specified by their Google Fonts names (or similar identifiers) during the build process and **self-host fonts** within the application, eliminating the need for external font services like Google Fonts.
- Utilize **preconnect**, **preload**, and **size-adjust** for optimal performance and seamless font rendering.
### Benefits :
- **Improved Performance:** Reduces reliance on external requests, minimizes layout shifts (thanks to the underlying CSS size-adjust) , and enables efficient caching.
- **Improved FCP and LCP:** Optimized fonts and proactive loading strategies contribute to significantly faster loading times and smoother user experiences.
- **Enhanced SEO:** Better Core Web Vitals can lead to higher search engine ranking and increased website traffic.
- **Enhanced Security:** Minimizes exposure to external vulnerabilities and provides more control over font sources.
- **Developer Experience:** Built-in font optimization in Angular improves developer experience.
### Alternatives considered
Anyone interested is welcome to comment on what the proposed syntax and feature set will be.
Inspired by next.js automatic font self-hosting library ( [next/font](https://nextjs.org/docs/app/api-reference/components/font) )
Guía de contribución
Línea de trabajo
Empieza revisando las áreas de @angular/core y @angular/cli relacionadas con el manejo de fuentes durante la compilación, y compara el comportamiento propuesto con Next.js next/font. Define los identificadores de fuentes compatibles, el flujo de descarga y self-hosting durante la compilación, y el comportamiento de preconnect, preload y size-adjust antes de la implementación. Se considera terminado cuando la funcionalidad funciona para Google Fonts y mejora los objetivos indicados de carga y desplazamiento del diseño.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- angular, typescript
- Área
- cli, frontend, performance
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 25/100