web-vitals icon indicating copy to clipboard operation
web-vitals copied to clipboard

Make web-vitals usable across frames (WIP)

Open ittaibaratz opened this issue 3 years ago • 1 comments

Hi @philipwalton , this PR is still WIP. Our use case might be niche so I want to get your POV before moving further.

Background:

Our main app embeds other apps using iframes. In cases where the iframe use the same origin as the parent, we want to avoid loading our runtime script (Which include web-vitals) twice in order to improve the iframe load performance.

Instead, we want the iframe to reach out to the parent and execute our script from there, which also calls webvitals when we measure & log load times.

The problem:

Web vitals in its current form interacts with the objects in the browser's global scope - window, document, etc. This is a problem for our use case since we want to use the script across same origin iframes.

The changes I am purposing will allow webvitals to run against any frame in a backward compatible manner, i.e.

getFID = (onReport: ReportHandler, reportAllChanges?: boolean, win = window)

I realize our use case might be niche and we'd better just do a fork, but wanted to check your POV. Also I wonder if there's a different way to meet our needs which does not require this type of rewrite?

Thanks! Ittai

ittaibaratz avatar Aug 03 '22 17:08 ittaibaratz

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.

google-cla[bot] avatar Aug 03 '22 17:08 google-cla[bot]

Closing this as quite out of date now.

tunetheweb avatar Oct 18 '23 19:10 tunetheweb