question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

polyfill usage with /base is counterintuitive

See original GitHub issue

Hi there. The how the polyfill works section states:

The “standard” version of the web-vitals library includes some of the same logic found in polyfill.js

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.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
noahnucommented, Jan 26, 2021

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.

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.

1reaction
roippicommented, Nov 23, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Polyfill - MDN Web Docs Glossary: Definitions of Web-related ...
A polyfill is a piece of code (usually JavaScript on the Web) used to provide modern functionality on older browsers that do not...
Read more >
When and How to Use Polyfills - Bits and Pieces - Bit.dev
A polyfill is a piece of code (usually JavaScript on the Web) used to provide modern functionality on older browsers that do not...
Read more >
Features | Vite
Vite uses esbuild to transpile TypeScript into JavaScript which is about 20~30x ... But it may be counter-intuitive for those coming from other...
Read more >
storybook action logger not working
Use this if your Storybook is already running, for example when part of a larger app. The Subtle Art of Not Giving a...
Read more >
Polyfills and transpilers - The Modern JavaScript Tutorial
Just don't forget to use a transpiler (if using modern syntax or operators) and polyfills (to add functions that may be missing).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found