diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 8298523..0d885c7 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -33,6 +33,11 @@ export default function RootLayout({ }>) { return ( + + + + + { + // Initialize performance monitoring + if (typeof window !== 'undefined' && 'performance' in window) { + const navigationStart = performance.timing?.navigationStart || 0; + const pageLoadTime = performance.timing?.loadEventEnd - navigationStart || 0; + + // Store performance metrics + if (!window.__performanceMetrics) { + window.__performanceMetrics = {}; + } + window.__performanceMetrics.navigationStart = navigationStart; + window.__performanceMetrics.pageLoadTime = pageLoadTime; + + // Log metrics for monitoring + if (process.env.NODE_ENV === 'development') { + console.log('[Performance] Page Load Time:', pageLoadTime, 'ms'); + } + + // Monitor Core Web Vitals using PerformanceObserver + try { + if ('PerformanceObserver' in window) { + const observer = new PerformanceObserver((list) => { + for (const entry of list.getEntries()) { + if (entry.name.includes('navigation')) { + window.__performanceMetrics!.navigationStart = (entry as any).startTime; + } + } + }); + observer.observe({ entryTypes: ['navigation', 'paint', 'largest-contentful-paint'] }); + } + } catch (e) { + // Gracefully handle PerformanceObserver not supported + } + } + }, []); + return (