Created
May 20, 2020 11:38
-
-
Save jecfish/3b0874bdb559768f3dd6c7b34abddc65 to your computer and use it in GitHub Desktop.
Test WebP Support
This file contains 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
/* test webp support, add .webp class to body */ | |
{ | |
canvas = typeof document === 'object' ? | |
document.createElement('canvas') : {}; | |
canvas.width = canvas.height = 1; | |
if (canvas.toDataURL && canvas.toDataURL('image/webp').indexOf('image/webp') === 5) { | |
document.querySelector('body').classList.add('webp') | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment