Created
July 22, 2012 20:43
-
-
Save madrobby/3161015 to your computer and use it in GitHub Desktop.
Detect retina support. Tested on iOS, Android 2.x, Chrome for Android, Safari on MacBook Pro Retina, Firefox mobile (beta) for Android, Opera Mobile (Android)
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 isRetina(){ | |
return (('devicePixelRatio' in window && devicePixelRatio > 1) || | |
('matchMedia' in window && matchMedia("(min-resolution:144dpi)").matches)) | |
} |
Also works on Chrome on MacBook Pro Retina (where window.devicePixelRatio==2
).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have updated the gist and moved away from the moz-specific check and test for
min-resolution:144dpi
. This works on Firefox (beta) on the Nexus 7, where as all other approaches (moz--min-device-pixel-ratio
andmin-resoution:1.5dppx
) didn't.