Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fregante/supports-webp
Detect support for WEBP images in the browser in 0.3KB
https://github.com/fregante/supports-webp
Last synced: 14 days ago
JSON representation
Detect support for WEBP images in the browser in 0.3KB
- Host: GitHub
- URL: https://github.com/fregante/supports-webp
- Owner: fregante
- License: mit
- Created: 2016-08-01T11:03:14.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-09-10T07:11:59.000Z (about 2 years ago)
- Last Synced: 2024-10-17T08:33:57.426Z (27 days ago)
- Language: JavaScript
- Homepage: https://npm.im/supports-webp
- Size: 17.6 KB
- Stars: 111
- Watchers: 3
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# supports-webp [![][badge-gzip]][link-bundlephobia]
> Detect support for WEBP images in the browser in 0.3KB
[badge-gzip]: https://img.shields.io/bundlephobia/minzip/supports-webp.svg?label=gzipped
[link-bundlephobia]: https://bundlephobia.com/result?p=supports-webp## Install
You can download the [standalone bundle](https://bundle.fregante.com/?pkg=supports-webp) and include it in your `manifest.json`.
Or use `npm`:
```sh
npm install --save supports-webp
```## Usage
```js
import supportsWebP from 'supports-webp';
// supportsWebP is a PromisesupportsWebP.then(supported => {
if (supported) {
console.log('Load WebP!');
} else {
console.log('Load JPEG!');
}
});// Or if you can use async/await:
if (await supportsWebP) {
console.log('Load WebP!');
} else {
console.log('Load JPEG!');
}
```