nuxt-modules / device

Nuxt module for detecting device type.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for browser detection

MrToxy opened this issue · comments

This library is pretty sweet, however, I feel that an important feature like browser detection is missing, given that the user agent is already available on the server-side, it would be amazing to also have the browser available.

You mean having something like isFirefox, isChrome, etc?

What would be the advantage of such flags?

This is a good idea.
Just one of many ideas of usage. By detecting browser we can use this module for images format setup.
For example, almost all browsers support WebP format, besides Safari for desktop and old IE.
Right now, in my project, i use this device-module and need to parse userAgent manually or use another js lib to detect browser. Good to do everything in one place :)

Quick note for another use case: detecting if the site is being browsed inside a snapchat/instagram/any embedded app browser. As some features break inside embedded browsers, and this could be useful for graceful degradation of features.

You mean having something like isFirefox, isChrome, etc?

What would be the advantage of such flags?

Sorry, I totally forgot about this, but yes that's exactly what I mean. I came across the need to know the browser version a couple of times but at the same time if the app was running on android, ios or just a web browser.

Furthermore, I believe this would present another interesting possibility, of dynamically injecting polyfills based on the browser, let's say that your app requires IntersectionObserver to lazy load images, then by detecting the browser you could inject a polyfill if that browser doesn't support it out of the box.

v2.1.0 has been released with support for browser detection.

However following features are not supported at least for now.

  • detection for embedded browser.
  • fetching browser version.