10 lines
325 B
TypeScript
Raw Normal View History

2019-11-18 02:04:13 +00:00
export default async function supportsWebP(): Promise<boolean> {
2019-03-26 06:06:15 +00:00
if(!window.createImageBitmap) {
return false
}
const data = "data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="
const blob = await fetch(data).then(r => r.blob())
return createImageBitmap(blob).then(() => true, () => false)
2019-11-17 09:44:30 +00:00
}