WebP image support for Firefox
This commit is contained in:
@ -1,3 +0,0 @@
|
||||
export function canUseWebP(): boolean {
|
||||
return document.createElement("canvas").toDataURL("image/webp").indexOf("data:image/webp") === 0
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
export * from "./canUseWebP"
|
||||
export * from "./supportsWebP"
|
||||
export * from "./delay"
|
||||
export * from "./findAll"
|
||||
export * from "./plural"
|
||||
|
9
scripts/Utils/supportsWebP.ts
Normal file
9
scripts/Utils/supportsWebP.ts
Normal file
@ -0,0 +1,9 @@
|
||||
export async function supportsWebP(): Promise<boolean> {
|
||||
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)
|
||||
}
|
Reference in New Issue
Block a user