Skip to content

Commit

Permalink
Add additional code comments
Browse files Browse the repository at this point in the history
  • Loading branch information
philipwalton committed Mar 11, 2024
1 parent 98d9090 commit c68c21b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/attribution/onINP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ const attributeINP = (metric: INPMetric): void => {
}
}

// If the browser supports the Long Animation Frame API and a
// `long-animation-frame` entry was found matching this interaction,
// use that entry's `renderTime` since it could be more accurate (and
// it accounts for non-event listener work such as timers or other
// pending tasks that could get run before rendering starts). If not,
// use the `processingEnd` value of the last entry in the list, which
// should match the `renderTime` value in most cases.
const renderStart = longAnimationFrameEntry
? longAnimationFrameEntry.renderStart
: lastEntry.processingEnd;
Expand Down
1 change: 1 addition & 0 deletions src/onINP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ const groupEntryByRenderTime = (entry: PerformanceEventTiming) => {
* and entries list is updated as needed.
*/
const processEntry = (entry: PerformanceEventTiming, renderTime: number) => {
// The least-long of the 10 longest interactions.
const minLongestInteraction =
longestInteractionList[longestInteractionList.length - 1];

Expand Down

0 comments on commit c68c21b

Please sign in to comment.