Created
November 6, 2012 22:09
-
-
Save bjankord/4027941 to your computer and use it in GitHub Desktop.
Test for 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
var img = new Image(), | |
supported = false; | |
img.src ="data:image/webp;base64,UklGRkYAAABXRUJQVlA4IDoAAABwAgCdASoEAAQAAYcIhYWIhYSIiQIADAzdrBLeABAAAAEAAAEAAPKn5Nn/0v8//Zxn/6H3QAAAAAA="; | |
img.onload = function() { supported = true; } | |
img.onerror = function(e) {} | |
window.onload = function() { | |
if (supported) { | |
document.getElementsByTagName('html')[0].className += ' webp'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment