Created
December 5, 2012 22:02
-
-
Save drewwells/4219907 to your computer and use it in GitHub Desktop.
Webkit+Moz detect device pixel ratio
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
var ratio = window.devicePixelRatio || | |
(function(i){ | |
var wmq = window.matchMedia; | |
while( !window.devicePixelRatio && i > 0 && | |
!wmq("(min--moz-device-pixel-ratio:" + i/10 + ")").matches ){ | |
i=i-1; | |
} | |
return i/10; | |
})(30); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I just searched google for this code and this appears to be exactly what I was looking for. How reliable is this? I am working on a cross-browser solution to serve retina icons for Google Maps.
Would this work on Firefox too? Obviously I will test this too, just wanted to get your feedback.