Created
January 16, 2018 09:06
-
-
Save Makazone/d8a6f69c4cbdbae9ce449f2289803a58 to your computer and use it in GitHub Desktop.
This snippet checks if browser supports web
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function supportsWebP () { | |
const canvas = typeof document === 'object' | |
? document.createElement('canvas') | |
: {} | |
canvas.width = canvas.height = 1 | |
return canvas.toDataURL | |
? canvas.toDataURL('image/webp').indexOf('image/webp') === 5 | |
: false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment