Created
January 21, 2023 09:38
-
-
Save Ankhena/1a996c3d3e2ffa6e26744f4925be6fa5 to your computer and use it in GitHub Desktop.
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
function checkWebP(callback){ | |
let webP = new Image(); | |
webP.onload = webP.onerror = function(){ | |
callback(webP.height == 2); | |
}; | |
webP.src = 'data:image/webp;base64,UklGRjoAAABXRUJQVlA4IC4AAACyAgCdASoCAAIALmk0mk0iIiIiIgBoSygABc6WWgAA/veff/0PP8bA//LwYAAA'; | |
}; | |
checkWebP(function(support){ | |
if(support) document.body.classList.add("webp"); | |
else document.body.classList.add("no-webp"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment