Last active
October 9, 2024 00:33
-
-
Save benjamincharity/6064532 to your computer and use it in GitHub Desktop.
Test for webp image support. From: http://stackoverflow.com/questions/5573096/detecting-webp-support#10930441
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 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