Watch1k
12/15/2017 - 12:59 PM

webp

check browser for webp support

/**
 * Webp support
 * @return {boolean} - true if supports
 */
export const canUseWebP = () => {
	const elem = document.createElement('canvas');
	
	if (!!(elem.getContext && elem.getContext('2d'))) {
		return elem.toDataURL('image/webp').indexOf('data:image/webp') === 0;
	}
	return false;
};