Using "navigator.userAgent" draws an issue in Chrome/Opera

Chrome/Opera draws an issue:

  1. Audit usage of navigator.userAgent, navigator.appVersion, and navigator.platform

  2. A page or script is accessing at least one of navigator.userAgent, navigator.appVersion, and navigator.platform. Starting in Chrome 101, the amount of information available in the User Agent string will be reduced.

To fix this issue, replace the usage of navigator.userAgent, navigator.appVersion, and navigator.platform with feature detection, progressive enhancement, or migrate to navigator.userAgentData.

Is “navigator.userAgentData” available in all browsers?
Could BJS get changed to use it please?

Adding @RaananW for this question :slight_smile:

No safari support, no firefox support - Navigator API: userAgentData | Can I use... Support tables for HTML5, CSS3, etc

I am happy for chrome that they are doing this, but I guess 50% of the sites are using the userAgent as a way to detect in what environment they are working.

Feature detection is an amazing way of finding out, but we had a lot of issues where patch or minor versions of certain browsers needed a patch, and that was only available in the userAgent (Fruity company, I am looking at you). Feature detection is also hard to maintain when it comes to different major versions of specific browsers. It works great if you need to know if something is available (for example - we use it in XR to check if the XR object is available. hence, feature detection :slight_smile: ). In some cases, the feature exists, but doesn’t work as expected. We have to be on top of all of these issues, to support any browser available.

2 Likes