Socket
Socket
Sign inDemoInstall

bowser

Package Overview
Dependencies
0
Maintainers
0
Versions
81
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

bowser


Version published
Maintainers
0
Created

Package description

What is bowser?

The bowser npm package is a browser detection library. It helps in identifying the browser and rendering engine a user is using, as well as providing information about the browser's capabilities, such as whether it supports touch events or service workers. This can be particularly useful for tailoring user experiences to different environments or for analytics and debugging purposes.

What are bowser's main functionalities?

Browser Detection

Detects the browser name using the user agent string.

const Bowser = require('bowser');
const browser = Bowser.getParser(window.navigator.userAgent);
const browserName = browser.getBrowserName();

Browser Version Detection

Determines the version of the browser being used.

const Bowser = require('bowser');
const browser = Bowser.getParser(window.navigator.userAgent);
const browserVersion = browser.getBrowserVersion();

Platform Detection

Identifies the platform (desktop, mobile, tablet, etc.) on which the browser is running.

const Bowser = require('bowser');
const browser = Bowser.getParser(window.navigator.userAgent);
const platformType = browser.getPlatformType();

Feature Checks

Checks if the browser supports certain features, such as touch events.

const Bowser = require('bowser');
const browser = Bowser.getParser(window.navigator.userAgent);
const supportsTouch = browser.satisfies({
  'mobile': { 'touch': true }
});

OS Detection

Determines the operating system on which the browser is running.

const Bowser = require('bowser');
const browser = Bowser.getParser(window.navigator.userAgent);
const osName = browser.getOSName();

Other packages similar to bowser

Readme

Source

Bowser

A Browser detector. Because sometimes, there is no other way, and not even good modern browser provide good feature detection mechanisms.

Works like this:

if (bowser().msie && bowser().version <= 6) {
  alert('hello China');
}

Detected Browsers

  • msie
  • safari[webkit]
  • chrome[webkit]
  • firefox[gecko]
  • opera

Notes

safari,chrome, and firefox will report that they have webkit|gecko engines

if (bowser().webkit) {
  // do stuff with safari & chrome
}

Ender installation

If you don't already have Ender (an npm package) install it now (and don't look back)

$ npm install ender

then add bowser to your module collection

$ ender add bowser

use it like this:

if ($.browser().chrome) {
  alert('Hello Silicon Valley');
}

FAQs

Last updated on 27 Apr 2011

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc