Skip to content
This repository
Browse code

webp image format test. fixes #245

  • Loading branch information...
commit d1fa2a62d7912d5f253ac1ab9ae2ce9430c3ef92 1 parent 3487408
Paul Irish authored May 21, 2011

Showing 1 changed file with 22 additions and 0 deletions. Show diff stats Hide diff stats

  1. 22  feature-detects/img-webp.js
22  feature-detects/img-webp.js
... ...
@@ -0,0 +1,22 @@
  1
+// code.google.com/speed/webp/
  2
+// by rich bradshaw, ryan seddon, and paul irish
  3
+
  4
+
  5
+// This test is ascynchronous. Watch out.
  6
+
  7
+(function(){
  8
+
  9
+  var image = new Image();
  10
+
  11
+
  12
+  image.onerror = function() {
  13
+      Modernizr.addTest('webp', function () { return false; });
  14
+  };  
  15
+  image.onload = function() {
  16
+      Modernizr.addTest('webp', function () { return image.width == 4; });
  17
+  };
  18
+
  19
+  image.src = 'data:image/webp;base64,UklGRjgAAABXRUJQVlA4ICwAAAAQAgCdASoEAAQAAAcIhYWIhYSIgIIADA1gAAUAAAEAAAEAAP7%2F2fIAAAAA';
  20
+
  21
+})();
  22
+

0 notes on commit d1fa2a6

Mike Taylor

s/ascynchronous/asynchronous/

:rainbow:

Mike Taylor

11 months too late... typical.

Please sign in to comment.
Something went wrong with that request. Please try again.