Skip to content

Instantly share code, notes, and snippets.

@bjankord
Created August 16, 2012 02:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjankord/3365812 to your computer and use it in GitHub Desktop.
Save bjankord/3365812 to your computer and use it in GitHub Desktop.
webP feature detect
/*
webP feature detect by jameswestgate
http://queryj.wordpress.com/2012/06/11/detecting-webp-support/
*/
function testWepP() {
var webP = new Image();
webP.src = 'data:image/webp;base64,UklGRjoAAABXRUJQVlA4IC4AAACyAgCdASoCAAIAL' +
'mk0mk0iIiIiIgBoSygABc6WWgAA/veff/0PP8bA//LwYAAA';
webP.onload = webP.onerror = function () {
callback(webP.height === 2);
};
};
testWebP(function(supported) {
console.log((supported) ? "webP supported!" : "webP not supported.");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment