diff --git a/index.html b/index.html index 896ef48..6f178f0 100644 --- a/index.html +++ b/index.html @@ -249,5 +249,6 @@

Title

+ diff --git a/package.json b/package.json index 3a5bfd0..91d44df 100644 --- a/package.json +++ b/package.json @@ -21,5 +21,8 @@ "license": "MIT", "engines": { "node": ">=18.0.0" + }, + "dependencies": { + "@vercel/speed-insights": "^2.0.0" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9b60ae1..78fcc3c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,4 +6,40 @@ settings: importers: - .: {} + .: + dependencies: + '@vercel/speed-insights': + specifier: ^2.0.0 + version: 2.0.0 + +packages: + + '@vercel/speed-insights@2.0.0': + resolution: {integrity: sha512-jwkNcrTeafWxjmWq4AHBaptSqZiJkYU5adLC9QBSqeim0GcqDMgN5Ievh8OG1rJ6W3A4l1oiP7qr9CWxGuzu3w==} + peerDependencies: + '@sveltejs/kit': ^1 || ^2 + next: '>= 13' + nuxt: '>= 3' + react: ^18 || ^19 || ^19.0.0-rc + svelte: '>= 4' + vue: ^3 + vue-router: ^4 + peerDependenciesMeta: + '@sveltejs/kit': + optional: true + next: + optional: true + nuxt: + optional: true + react: + optional: true + svelte: + optional: true + vue: + optional: true + vue-router: + optional: true + +snapshots: + + '@vercel/speed-insights@2.0.0': {} diff --git a/speed-insights.js b/speed-insights.js new file mode 100644 index 0000000..5ae9592 --- /dev/null +++ b/speed-insights.js @@ -0,0 +1,50 @@ +/** + * Vercel Speed Insights Integration + * + * Initializes Vercel Speed Insights for performance monitoring. + * This script is loaded after the main app initialization. + */ + +(function() { + 'use strict'; + + // Initialize the Speed Insights queue + window.si = window.si || function() { + (window.siq = window.siq || []).push(arguments); + }; + + // Load the Speed Insights script + function loadSpeedInsights() { + // Check if script is already loaded + const existingScript = document.querySelector('script[src*="speed-insights"]'); + if (existingScript) { + return; + } + + // Create script element + const script = document.createElement('script'); + + // Use the Vercel-hosted script + script.src = '/_vercel/speed-insights/script.js'; + script.defer = true; + + // Add SDK information + script.dataset.sdkn = '@vercel/speed-insights'; + script.dataset.sdkv = '2.0.0'; + + // Handle load errors + script.onerror = function() { + console.warn('[Vercel Speed Insights] Failed to load script. This is expected in local development.'); + }; + + // Append to document head + document.head.appendChild(script); + } + + // Load when DOM is ready + if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', loadSpeedInsights); + } else { + loadSpeedInsights(); + } +})();