Files
aitbc/website/assets/js/web-vitals.js
AITBC System b033923756 chore: normalize file permissions across repository
- Remove executable permissions from configuration files (.editorconfig, .env.example, .gitignore)
- Remove executable permissions from documentation files (README.md, LICENSE, SECURITY.md)
- Remove executable permissions from web assets (HTML, CSS, JS files)
- Remove executable permissions from data files (JSON, SQL, YAML, requirements.txt)
- Remove executable permissions from source code files across all apps
- Add executable permissions to Python
2026-03-08 11:26:18 +01:00

29 lines
1.0 KiB
JavaScript

// Web Vitals monitoring for AITBC
// Tracks Core Web Vitals: LCP, FID, CLS, TTFB, FCP
(function() {
'use strict';
function sendToAnalytics(metric) {
const safeValue = Number.isFinite(metric.value) ? Math.round(metric.value) : 0;
// In production we log to console. The /api/web-vitals endpoint was removed
// to reduce unnecessary network noise as we are not running a telemetry backend.
console.log(`[Web Vitals] ${metric.name}: ${safeValue}`);
}
// Load web-vitals from CDN
const script = document.createElement('script');
script.src = 'https://unpkg.com/web-vitals@3/dist/web-vitals.iife.js';
script.onload = function() {
if (window.webVitals) {
window.webVitals.onCLS(sendToAnalytics);
window.webVitals.onFID(sendToAnalytics);
window.webVitals.onLCP(sendToAnalytics);
window.webVitals.onFCP(sendToAnalytics);
window.webVitals.onTTFB(sendToAnalytics);
}
};
document.head.appendChild(script);
})();