Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[soft-navigation] expose reset for cls and inp on navigation #587

Conversation

mattkubej
Copy link

Description

This PR exposes reset functions for the return values of onCLS and onINP. These functions allow for resetting the metric measurements, particularly useful in single-page applications (SPAs) with soft navigation.

Motivation

Surface web-vitals performance signals on soft-navigation within SPAs.

Soft-navigation is an experimental feature within Chrome, but we can instrument SPAs to observe signals during soft-navigation. Resetting the observability of CLS and INP on soft-navigation, as signaled by the client, will provide us additional context on the performance of soft-navigations.

How to use

const { reset: resetCLS } = onCLS(handleCLS, { reportAllChanges: true });
const { reset: resetINP } = onINP(handleINP, { reportAllChanges: true });

function onSoftNavigation() {
 resetCLS();
 resetINP();
}

Similar to the batching example, clients could collect groups of events for each soft-navigation and report on them.

Copy link

google-cla bot commented Jan 29, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@tunetheweb
Copy link
Member

Hi @mattkubej , thanks for the PR. This has been suggested a few times before, but we are not currently looking to implement this into the library, for the reasons given in #448 (comment) and #448 (comment).

We're hoping to make more progress on the Chrome side this year, and so the soft navs experimental support in this library

@tunetheweb tunetheweb closed this Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants