Last active
October 19, 2015 10:50
-
-
Save aFarkas/2c4531393f9b1d18243c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
'use strict'; | |
var width2 = 'data:image/gif;base64,R0lGODlhAgABAPAAAP///wAAACH5BAAAAAAALAAAAAACAAEAAAICBAoAOw=='; | |
var width1 = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=='; | |
var img = document.createElement('img'); | |
var test = function(){ | |
var width = img.width; | |
if(width == 2){ | |
alert('your browser support sizes'); | |
} else { | |
alert('your browser does not support sizes'); | |
} | |
}; | |
img.onload = test; | |
img.onerror = test; | |
img.setAttribute('sizes', '9px'); | |
img.srcset = width1 + ' 1w,' + width2 + ' 8w'; | |
img.src = width1; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment