Skip to content

Instantly share code, notes, and snippets.

@benjamincharity
Created May 4, 2013 15:22
Show Gist options
  • Save benjamincharity/5517798 to your computer and use it in GitHub Desktop.
Save benjamincharity/5517798 to your computer and use it in GitHub Desktop.
Modernizr test for datauri (base64 encoded images).
// data uri test.
// https://github.com/Modernizr/Modernizr/issues/14
// This test is ascynchronous. Watch out.
(function(){
var datauri = new Image();
datauri.onerror = function() {
Modernizr.addTest('datauri', function () { return false; });
};
datauri.onload = function() {
Modernizr.addTest('datauri', function () { return (datauri.width == 1 && datauri.height == 1); });
};
datauri.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment