Giter Club home page Giter Club logo

supports.js's Introduction

⚡ 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

supports.js's People

Contributors

dependabot-support avatar

Stargazers

Kenny Alvizuris avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.