auto-claude: subtask-3-2 - Add JSDoc to fontLoader.ts

This commit is contained in:
2026-01-25 06:42:26 +01:00
parent 4d9e0d3a29
commit b4f9ac947b
+18 -5
View File
@@ -1,4 +1,13 @@
// Font loading utility to ensure fonts are loaded before showing content
/**
* Font Loading Utility
* Ensures fonts are loaded before showing content to prevent FOUT/FOIT
*/
/**
* Preload fonts asynchronously
* Uses the Font Loading API to ensure Inter font is loaded
* Falls back to system fonts on error
*/
export const preloadFonts = async () => {
if ('fonts' in document) {
try {
@@ -12,14 +21,18 @@ export const preloadFonts = async () => {
}
};
// Call this function as early as possible
/**
* Initialize font loading process
* Should be called as early as possible in the application lifecycle
* Adds loading state and fallback timeout to prevent indefinite loading
*/
export const initializeFonts = () => {
// Add loading class immediately
document.documentElement.classList.add('fonts-loading');
// Start font loading
preloadFonts();
// Remove loading class after a timeout to prevent indefinite loading state
setTimeout(() => {
document.documentElement.classList.remove('fonts-loading');
@@ -27,4 +40,4 @@ export const initializeFonts = () => {
document.documentElement.classList.add('fonts-fallback');
}
}, 3000);
};
};