2.1.8 • Published 6 years ago
browser-version-detection v2.1.8
Detect browser
Browser detection using the user agent. Tested on most popular browser in the World on October 2017, statistic gets from StatCounter.
It's worth re-iterating: it's very rarely a good idea to use user agent sniffing. You can almost always find a better, more broadly compatible way to solve your problem!
More details here
Usage
Installation
npm i browser-version-detection
Script returns object with browser name and version, for example:
const output = {
name: 'Chrome',
version: 62,
}
Call it where you want
browserDetection.detectBrowser(window.navigator);
in case if you need only name
browserDetection.detectBrowserName(window.navigator.userAgent)
in case if you need only version
const name = browserDetection.detectBrowserName(window.navigator.userAgent);
browserDetection.detectBrowserVersion(window.navigator, name)
Note: also it's possible to use npm instead of yarn.
Minified script located in dist/
folder
Contribution
yarn install
yarn run start
Test
yarn test