-
Notifications
You must be signed in to change notification settings - Fork 400
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
polyfill usage with /base is counterintuitive #95
Comments
You do not need to include the polyfill script or use The only way it will break is if you do not add the polyfill script but then you import I thought it was clear in the documentation that it had to be one or the other. If you think it's not clear, let me know.
The polyfill is just polyfilling. Where I agree it's confusing is that the "standard" version is also polyfilling—it's just not polyfilling as much stuff. What it's polyfilling is the detection of the metrics after a bfcache restore. The only reason there are two scripts is because regular FID cannot be polyfilled without adding code to the And since some of the code required to detect FID cross-browser is also required to detect FID after a bfcache restore, it made sense to have two versions of the script to avoid duplication when using the polyfill. I agree it'd be simpler to have just one version, but I thought it was worth a bit of confusion to avoid the duplication. Once there are APIs to detect bfcache versions of these metrics, then the |
I work for a large e-commerce website; we want to capture webvitals for all of our customers. 60-70% of our mobile traffic is safari. It is not feasible to bundle different versions of webvitals for different browsers. Thus, we need to use
It is clear. It is also counterintuitive, and not everyone reads every letter of the documentation when implementing. We didn't. It caused our webvitals to break for a bit, because we omitted the polyfill for chrome. I do not think it is unreasonable to ask for something labeled a
|
Yes, that's correct. This is expected, and this is what is documented. Shipping Also, keep in mind that even Chrome benefits from the polyfill, as it gets a (potentially) more accurate recording of the page's visibility state when it was loaded. In addition, it could be the case in the future that the polyfill is ahead of Chrome, so it's not a safe assumption that Chrome will never need the polyfill. If you want to use the polyfill and get Safari support, then you have to use it with the
The polyfill is a pure polyfill. Your issue was caused by using As I said before, I agree and understand that this is not the way that libraries are typically added to a page, but there's no other way to measure FID in all browsers other than to have a separate script added to the If you have a suggestion for a better for |
Thanks for the response. I will be on hiatus for the next week and can reply next Monday. Hope you and everyone else reading this has a happy and safe holiday. |
I think it can be clarified. We ran into the same issue where we operated under the faulty assumption that in the worst case, a missing polyfill would just mean no data. I assumed I would still be able to call getFID, and that the onReport callback would just never be triggered if it wasn't supported. Instead, without the polyfill, getFID raises an uncaught exception. It'd be valuable to update the documentation to call out that without the polyfill, use of the web vitals base script may produce undefined behaviour, and not just "missing data". Alternatively, in my opinion it's more intuitive to have the various getMetric functions just become no-ops if there is not sufficient information to trigger the onReport handler. |
Closing this a the polyfill is deprecated and will be removed in a future version. Plus it's primary use case is for FID which is less relevant now that INP is due to replace it. |
Hi there. The how the polyfill works section states:
This means that you must include the polyfill, even on browsers (ie chrome) that natively support First Input Delay. Omitting the polyfill will break FID on chrome. (
Cannot read property 'firstHiddenTime' of undefined
)This is rather counterintuitive: it means the polyfill is doing more than just polyfilling. It's bundling some application logic in with the polyfill. I've never seen another polyfill on the web that acts this way - a reasonable developer expectation is that polyfills replace missing browser functionality, and no more.
Can we make the polyfill pure, and leave application logic inside the app? Alternately, calling this something other than a "polyfill" since it's really a polyfill + helper script. Thanks.
The text was updated successfully, but these errors were encountered: