Created
February 26, 2020 07:21
-
-
Save wadadanet/36ba1ba21d6eb46490e41e257cc68a1e to your computer and use it in GitHub Desktop.
ブラウザがWebPをサポートしているかどうか
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
export default function() { | |
var elem = document.createElement('canvas') | |
if (!!(elem.getContext && elem.getContext('2d'))) { | |
// was able or not to get WebP representation | |
return elem.toDataURL('image/webp').indexOf('data:image/webp') == 0 | |
} | |
// very old browser like IE 8, canvas not supported | |
return false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment