supports-webp
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

supports-webp

Detect support for WEBP images in the browser in 0.3KB

Install

You can download the standalone bundle and include it in your manifest.json.

Or use npm:

npm install --save supports-webp

Usage

import supportsWebP from 'supports-webp';
// supportsWebP is a Promise

supportsWebP.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!');
}

Package Sidebar

Install

npm i supports-webp

Weekly Downloads

47,222

Version

3.0.0

License

MIT

Unpacked Size

3.02 kB

Total Files

5

Last publish

Collaborators

  • fregante