Skip to content

⚡ A fast, simple, lightweight and dependency-free feature-detection library

License

Notifications You must be signed in to change notification settings

metacurb/Supports.js

Repository files navigation

⚡ Supports.js

Supports.js is a fast, lightweight and dependency-free feature-detection library. It's the best way to check a user's browser for those features that your latest projects make use of.

The aim of Supports.js is to make feature-detection quick and painless. Import what you need, and leave the rest. Everything returns a Boolean, for ease-of-use.

Getting Started

In the browser

<script src="//unpkg.com/supports.js/supports.min.js"></script>
if (supports.touchevents) {
  console.log('Touch events supported');
}

Using npm

$ npm i supports.js
import supports from 'supports.js';

if (supports.touchevents) {
  console.log('Touch events supported');
}

API Reference

Methods:

supports.some(args)

  • args <Array<String>>
  • returns: <Boolean> true if at least one feature in the array is supported by the browser.

Example:

supports.some(['websqldatabase', 'webworkers', 'serviceworker']);

supports.every(args)

  • args <Array<String>>
  • returns: <Boolean> true if every feature in the array is supported by the browser.

Example:

supports.every(['geolocation', 'touchevents', 'canvas']);

Properties:

supports.classlist
supports.devicemotion
supports.deviceorientation
supports.fetch
supports.filereader
supports.geolocation
supports.history
supports.intl
supports.matchmedia
supports.serviceworkers
supports.touchevents
supports.webgl
supports.webgl2
supports.webworkers

NOTE Supports.js checks to see if Touch events are supported within a device browser. It relies on the browser to detect if touch support is available. It does NOT check to see if the device itself is a touch device.

License

Supports.js uses the MIT license

Contributing

  1. Fork it (https://github.com/yourname/yourproject/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

Releases

No releases published

Packages

No packages published