Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

webp image format test. fixes #245

  • Loading branch information...
commit d1fa2a62d7912d5f253ac1ab9ae2ce9430c3ef92 1 parent 3487408
@paulirish paulirish authored
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.

s/ascynchronous/asynchronous/

:rainbow:

@paulirish Owner

hah! @mathiasbynens beat you to it: d704496

11 months too late... typical.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+
+(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';
+
+})();
+
@miketaylr

s/ascynchronous/asynchronous/

:rainbow:

@miketaylr

11 months too late... typical.

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