Skip to content

Instantly share code, notes, and snippets.

@jakearchibald
Last active February 25, 2024 04:22
Show Gist options
  • Save jakearchibald/6c43d5c454bc8f48f83d8471f45698fa to your computer and use it in GitHub Desktop.
Save jakearchibald/6c43d5c454bc8f48f83d8471f45698fa to your computer and use it in GitHub Desktop.
async function supportsWebp() {
if (!self.createImageBitmap) return false;
const webpData = 'data:image/webp;base64,UklGRhIAAABXRUJQVlA4TAYAAAAvQWxvAGs=';
const blob = await fetch(webpData).then(r => r.blob());
return createImageBitmap(blob).then(() => true, () => false);
}
addEventListener('install', event => {
event.waitUntil(async function() {
if (await supportsWebp()) {
// …
}
else {
// …
}
}());
});
@jakearchibald
Copy link
Author

It should do

@kane-mason
Copy link

Mmm iOS 14 beta 2 has no support for createImageBitmap, yet?

@kane-mason
Copy link

Actually not seeing any webp support of any kind yet, guess its still coming

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment