Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -249,5 +249,6 @@ <h2 id="watchTitle">Title</h2>

<script src="update-manager.js?v=142"></script>
<script src="app.js?v=142"></script>
<script src="speed-insights.js?v=142"></script>
</body>
</html>
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,8 @@
"license": "MIT",
"engines": {
"node": ">=18.0.0"
},
"dependencies": {
"@vercel/speed-insights": "^2.0.0"
}
}
38 changes: 37 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 50 additions & 0 deletions speed-insights.js
Original file line number Diff line number Diff line change
@@ -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();
}
})();