getAllGoogleFontsUrls
Returns an array of all unique Google Fonts URLs used across all font pairings in the registry.Function Signature
lib/pairings.ts
Returns
Array of all unique Google Fonts URLs across all pairings
Description
ThegetAllGoogleFontsUrls() function extracts and returns all unique Google Fonts URLs from every pairing in the registry. Each URL contains the font families and weights needed for a pairing. This is useful for preloading fonts, analyzing font usage, or building font loading strategies.
Usage Examples
Basic Usage
Preload All Fonts
Generate Font Loading Stylesheet
Check Font Loading Performance
Generate Next.js Font Configuration
Build Font Subset Optimizer
URL Format
Each Google Fonts URL follows this format:URLs typically include multiple font families (heading, body, mono) with their respective weights combined in a single request for optimal loading performance.
Related Functions
getPairingGoogleFontsUrl
Get Google Fonts URL for a specific pairing
getAllPairings
Get all available pairings
Notes
- URLs are extracted from the
googleFontsUrlfield of each pairing - The function deduplicates URLs automatically using a Set
- Returns an array of strings in no particular order
- Pairings without a
googleFontsUrlare skipped (though all current pairings include this field) - Each URL is already optimized with
display=swapfor better performance - Performance: O(n) where n is the number of pairings
Best Practices
Preconnect to Google Fonts
Preconnect to Google Fonts
Add preconnect hints in your HTML head to speed up font loading:
Use font-display: swap
Use font-display: swap
All Fonttrio URLs include
display=swap by default, which shows fallback text immediately while fonts load.Subset Fonts for Language Support
Subset Fonts for Language Support
Consider adding subset parameters if you only need specific character sets (latin, latin-ext, cyrillic, etc.).
Source Reference
Implementation:lib/pairings.ts:53-61