-
-
Save jakearchibald/6c43d5c454bc8f48f83d8471f45698fa 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
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 { | |
// … | |
} | |
}()); | |
}); |
Yes, you are not using webpData anywhere :)
Also why not cache the result of supportsWebp ?
Maybe use the webpData in line 5?
NO I LIKE TO WASTE BYTES
fixed
shave a few off your data uri with data:image/webp;base64,UklGRhIAAABXRUJQVlA4TAYAAAAvQWxvAGs=
(pulled from mathias' small)
Not working in iphone 6s. Issue causing due to async function. Similar issue on SO.
https://stackoverflow.com/questions/53358706/angular-web-app-async-functions-observables-not-working-properly-in-ios-devi
iOS14 introduces webp support, anyone know if this will detect there correctly?
It should do
Mmm iOS 14 beta 2 has no support for createImageBitmap, yet?
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
Maybe use the
webpData
in line 5?