Skip to content

Instantly share code, notes, and snippets.

@apeli23
Created August 19, 2021 15:20
Show Gist options
  • Save apeli23/9890e7fcc5c65175aabb38365fb4db51 to your computer and use it in GitHub Desktop.
Save apeli23/9890e7fcc5c65175aabb38365fb4db51 to your computer and use it in GitHub Desktop.
react report web vitals
const reportWebVitals = onPerfEntry => {
if (onPerfEntry && onPerfEntry instanceof Function) {
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
getCLS(onPerfEntry);
getFID(onPerfEntry);
getFCP(onPerfEntry);
getLCP(onPerfEntry);
getTTFB(onPerfEntry);
});
}
};
export default reportWebVitals;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment