Skip to content

Commit

Permalink
feat(frontend): fix web vitals
Browse files Browse the repository at this point in the history
  • Loading branch information
hkdeman committed Sep 4, 2024
1 parent ab69f53 commit 003050c
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions frontend/src/reportWebVitals.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { ReportHandler } from 'web-vitals';
import { CLSMetric, FCPMetric, FIDMetric, LCPMetric, TTFBMetric } from 'web-vitals';

type ReportHandler = (metric: CLSMetric | FIDMetric | FCPMetric | LCPMetric | TTFBMetric) => void;

const reportWebVitals = (onPerfEntry?: ReportHandler) => {
if (onPerfEntry && onPerfEntry instanceof Function) {
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
getCLS(onPerfEntry);
getFID(onPerfEntry);
getFCP(onPerfEntry);
getLCP(onPerfEntry);
getTTFB(onPerfEntry);
import('web-vitals').then(({ onCLS, onFCP, onLCP, onTTFB }) => {
onCLS(onPerfEntry);
onFCP(onPerfEntry);
onLCP(onPerfEntry);
onTTFB(onPerfEntry);
});
}
};
Expand Down

0 comments on commit 003050c

Please sign in to comment.