Skip to content

Instantly share code, notes, and snippets.

@li0nel
Created July 12, 2018 14:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save li0nel/77b828979cb6bd7f9f47c036674a4d67 to your computer and use it in GitHub Desktop.
Save li0nel/77b828979cb6bd7f9f47c036674a4d67 to your computer and use it in GitHub Desktop.
supportsWebp.js
var supportsWebp = async function() {
if (!self.createImageBitmap) return false;
const webpData = 'data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA=';
const blob = await fetch(webpData).then(r => r.blob());
return createImageBitmap(blob).then(() => true, () => false);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment