Skip to content

Instantly share code, notes, and snippets.

@Dzinlife
Last active December 26, 2015 13:19
Show Gist options
  • Save Dzinlife/7157284 to your computer and use it in GitHub Desktop.
Save Dzinlife/7157284 to your computer and use it in GitHub Desktop.
Firefox 14.0.1
window.retina => undefined
window.devicePixelRatio => undefined
Chrome 21.0.1180.57
window.devicePixelRatio => 2
window.retina => undefined
Safari 6.0 (8536.25)
window.retina => true
window.devicePixelRatio => 2
var retina = (window.retina || window.devicePixelRatio > 1);
if (retina) {
//retina display
//load high resolution picture
$(img).src = 'high-res.jpg';
}
else {
//non-retina display
//load low resolution picture
$(img).src = 'high-res.jpg';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment