// https://developers.google.com/speed/webp/faq#how_can_i_detect_browser_support_for_webp // 'callback(feature, result)' will be passed back the detection result (in an asynchronous way!) export const checkWebPSupport = callback => { const kTestImages = { lossy: 'UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA' } const img = new Image() img.onload = () => { const result = img.width > 0 && img.height > 0 callback(result) } img.onerror = function() { callback(false) } img.src = 'data:image/webp;base64,' + kTestImages.lossy }