Permalink
Browse files

webp image format test. fixes #245

  • Loading branch information...
1 parent 3487408 commit d1fa2a62d7912d5f253ac1ab9ae2ce9430c3ef92 @paulirish paulirish committed May 21, 2011
Showing with 22 additions and 0 deletions.
  1. +22 −0 feature-detects/img-webp.js
View
22 feature-detects/img-webp.js
@@ -0,0 +1,22 @@
+// code.google.com/speed/webp/
+// by rich bradshaw, ryan seddon, and paul irish
+
+
+// This test is ascynchronous. Watch out.
@miketaylr
miketaylr Jun 13, 2012

s/ascynchronous/asynchronous/

🌈

@miketaylr
miketaylr Jun 13, 2012

11 months too late... typical.

+
+(function(){
+
+ var image = new Image();
+
+
+ image.onerror = function() {
+ Modernizr.addTest('webp', function () { return false; });
+ };
+ image.onload = function() {
+ Modernizr.addTest('webp', function () { return image.width == 4; });
+ };
+
+ image.src = 'data:image/webp;base64,UklGRjgAAABXRUJQVlA4ICwAAAAQAgCdASoEAAQAAAcIhYWIhYSIgIIADA1gAAUAAAEAAAEAAP7%2F2fIAAAAA';
+
+})();
+

0 comments on commit d1fa2a6

Please sign in to comment.