Code Monkey home page Code Monkey logo

Comments (4)

talsafran avatar talsafran commented on June 4, 2024 1

Thanks @Zizzamia @philipwalton ❤️

I recommend not checking :)

Okay – that's good to know 😄. I guess I was worried about some browsers reporting wrong/incomplete data, which would skew our numbers.

However, some of the APIs required to capture these metrics are only available in Chromium-based browsers (e.g. Chrome, Edge, Opera, Samsung Internet).

So just to be clear –– a browser that doesn't support a given metric (like Safari + FID) will just not report anything, right?

from web-vitals.

philipwalton avatar philipwalton commented on June 4, 2024 1

Okay – that's good to know 😄. I guess I was worried about some browsers reporting wrong/incomplete data, which would skew our numbers.

I mean, if a browser is reporting bad data, there's only so much the library can do to prevent that. For obviously incorrect data, the library can simply not report those cases, but for incorrect—but not obviously incorrect :)—data, we'd likely just have to report it.

Note: the FID polyfill works around some obvious errors in older browsers, which means those won't be reported by the web-vitals library either.

So just to be clear –– a browser that doesn't support a given metric (like Safari + FID) will just not report anything, right?

Yep, exactly.

from web-vitals.

Zizzamia avatar Zizzamia commented on June 4, 2024

Great feedback @talsafran!

Have a clear list of where the Browser does or does not support a feature is not quite simple for these APIs. In the past, we had cases like Firefox v58 that had an old issue related to using PerformanceObserver with entryTypes 'paint': https://bugzilla.mozilla.org/show_bug.cgi?id=1403027 . Which the only way to prevent that was with a try/catch, me and @philipwalton had some thoughts around this on #7

With each browser implementing fully or partially those new APIs, it is quite hard to draw a clear line where the browser does or does not support the feature. What I notice the best way is "Approach 2: Check if some API exists" mix with some old school try/catch for edge cases where the browser failed the early implementation.

Those were my quick 2cents, I am sure @philipwalton will share a better 360 overview on your question 😁

from web-vitals.

philipwalton avatar philipwalton commented on June 4, 2024

How do you currently recommend checking if this library is supported by the user agent?

I recommend not checking :)

Anyway wondering what your thoughts were. I think that ultimately it would be best if the library just abstracted away the browser support question 😄

Yep, that's exactly what it does today. If the browser does not support the API, your callback will not be fired (in that browser).

I've tried to make that clear in the documentation, but maybe what I've written is not sufficient? Any suggestions for how to make it more clear?

This code has been tested and will run without error in all major browsers as well as Internet Explorer back to version 9 (when transpiled to ES5). However, some of the APIs required to capture these metrics are only available in Chromium-based browsers (e.g. Chrome, Edge, Opera, Samsung Internet).

from web-vitals.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.