Skip to content

Commit

Permalink
add method to measure Interaction to Next Paint (INP)
Browse files Browse the repository at this point in the history
  • Loading branch information
Keen Yee Liau committed Apr 26, 2022
1 parent 90863c7 commit a238eb5
Show file tree
Hide file tree
Showing 9 changed files with 113,923 additions and 113,843 deletions.
4 changes: 4 additions & 0 deletions docs/advanced-features/measuring-performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ experience of a web page. The following web vitals are all included:
- [Largest Contentful Paint](https://web.dev/lcp/) (LCP)
- [First Input Delay](https://web.dev/fid/) (FID)
- [Cumulative Layout Shift](https://web.dev/cls/) (CLS)
- [Experimental: Interaction to Next Paint](https://web.dev/responsiveness/) (INP)

You can handle all the results of these metrics using the `web-vital` label:

Expand Down Expand Up @@ -85,6 +86,9 @@ export function reportWebVitals(metric) {
case 'TTFB':
// handle TTFB results
break
case 'INP':
// handle INP results
break
default:
break
}
Expand Down
22 changes: 12 additions & 10 deletions packages/next/client/performance-relayer.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/* global location */
import {
getCLS,
getFCP,
getFID,
getLCP,
getTTFB,
onCLS,
onFCP,
onFID,
onINP,
onLCP,
onTTFB,
Metric,
ReportHandler,
} from 'next/dist/compiled/web-vitals'
Expand Down Expand Up @@ -81,9 +82,10 @@ export default (onPerfEntry?: ReportHandler): void => {
}
isRegistered = true

getCLS(onReport)
getFID(onReport)
getFCP(onReport)
getLCP(onReport)
getTTFB(onReport)
onCLS(onReport)
onFID(onReport)
onFCP(onReport)
onLCP(onReport)
onTTFB(onReport)
onINP(onReport)
}
149 changes: 112 additions & 37 deletions packages/next/compiled/babel-packages/packages-bundle.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions packages/next/compiled/babel/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/next/compiled/web-vitals/web-vitals.umd.js

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

Loading

0 comments on commit a238eb5

Please sign in to comment.