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.
<script src="//unpkg.com/supports.js/supports.min.js"></script>
if (supports.touchevents) {
console.log('Touch events supported');
}
$ npm i supports.js
import supports from 'supports.js';
if (supports.touchevents) {
console.log('Touch events supported');
}
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']);
args
<Array<String>>- returns: <Boolean>
true
if every feature in the array is supported by the browser.
Example:
supports.every(['geolocation', 'touchevents', 'canvas']);
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.
Supports.js uses the MIT license
- Fork it (https://github.com/yourname/yourproject/fork)
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request