Built-In Font Optimization: Improve Angular Performance & Core Web Vitals
- 主要語言
- TypeScript
- 星號
- 27k
- 分支
- 11.8k
- 平均合併
- 14 小時 23 分鐘
- 30 天內合併 PR
- 162
描述
### 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) )
貢獻指南
研究方向
先檢視 @angular/core 和 @angular/cli 中涉及建置時字型處理的區域,並將提議的行為與 Next.js next/font 進行比較。在實作之前,定義支援的字型識別碼、建置時下載與自託管流程,以及 preconnect、preload 和 size-adjust 的行為。此功能能夠支援 Google Fonts,並改善所述的載入與版面配置偏移目標,即視為完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- angular, typescript
- 領域
- cli, frontend, performance
- Issue 類型
- 功能
- 難度
- 5/5
- 預估耗時
- 一週以上
- 活躍度
- 停滯
- 描述清晰度
- 需要釐清
- 新手友好度
- 25/100