Created
June 27, 2014 20:31
-
-
Save dillonhafer/efca3fcf3fe895a093fc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var Retina = Retina || {}; | |
Retina = { | |
init: function() { | |
var images = document.querySelectorAll("img[data-1x]"); | |
var attr = Retina.isRetina() ? "data-2x" : "data-1x"; | |
Array.prototype.forEach.call(images, function(el, i) { | |
var src = el.getAttribute(attr); | |
el.setAttribute("src", src); | |
}); | |
}, | |
isRetina: function() { | |
return window.devicePixelRatio == 2; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment