Skip to content

Instantly share code, notes, and snippets.

@benjamincharity
Last active July 23, 2017 04:19
Show Gist options
  • Save benjamincharity/6064532 to your computer and use it in GitHub Desktop.
Save benjamincharity/6064532 to your computer and use it in GitHub Desktop.
function testWebP(callback) {
var webP = new Image();
webP.src = 'data:image/webp;base64,UklGRjoAAABXRUJQVlA4IC4AAACyAgCdASoCAAIALmk0mk0iIiIiIgBoSygABc6WWgAA/veff/0PP8bA//LwYAAA';
webP.onload = webP.onerror = function () {
callback(webP.height === 2);
};
};
function notify(supported) {
console.log((supported) ? "webP supported!" : "webP not supported.");
}
testWebP(notify);​
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment