Where did you install Firefox from? Help Mozilla uncover 3rd party websites that offer problematic Firefox installation by taking part in our campaign. There will be swag, and you'll be featured in our blog if you manage to report at least 10 valid reports!

Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

Firefox 93 on linux returns type of image/png when querying for webp

more options

Hmm, not sure mozilla support is the right place, and I can't get 'matrix' working at all, since irc is no longer supported.

I want to use javascript to detect whether the browser has webp support. This is the recommended javascript technique... ``` function canUseWebP() {

   var elem = document.createElement('canvas');    if (!!(elem.getContext && elem.getContext('2d'))) {
       // was able or not to get WebP representation
       return elem.toDataURL('image/webp').indexOf('data:image/webp') == 0;
   }    // very old browser like IE 8, canvas not supported
   return false;

} ``` but elem.toDataURL('image/webp') returns a binary blob that has 'image/png' as a header.

Why does Firefox return 'image/png' when it should return 'image/webp'?

Hmm, not sure mozilla support is the right place, and I can't get 'matrix' working at all, since irc is no longer supported. I want to use javascript to detect whether the browser has webp support. This is the recommended javascript technique... ``` function canUseWebP() { var elem = document.createElement('canvas'); if (!!(elem.getContext && elem.getContext('2d'))) { // was able or not to get WebP representation return elem.toDataURL('image/webp').indexOf('data:image/webp') == 0; } // very old browser like IE 8, canvas not supported return false; } ``` but elem.toDataURL('image/webp') returns a binary blob that has 'image/png' as a header. Why does Firefox return 'image/png' when it should return 'image/webp'?

All Replies (1)

more options

Judging from the following table, it looks like Firefox won't support 'image/webp' as a parameter of toDataURL() until the next release, Firefox 96:

https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL#browser_compatibility

Why do you need to test for WebP support using a script?