Last active
December 18, 2018 20:34
-
-
Save neodigm/234b8ea6e2ee3db1f3e21b0d3f326023 to your computer and use it in GitHub Desktop.
JavaScript WebP support detection
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 canIUseWebP() { // Original Author Unknown | |
var elem = document.createElement('canvas'); | |
if (!!(elem.getContext && elem.getContext('2d'))) { | |
return elem.toDataURL('image/webp').indexOf('webp') == 0; | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment