Created
November 27, 2013 13:46
-
-
Save joaocunha/7675924 to your computer and use it in GitHub Desktop.
Modernizr test for retina / high resolution / high pixel density.
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
/** | |
* Modernizr test for retina / high resolution / high pixel density | |
* | |
* @author Joao Cunha | |
* @license MIT | |
*/ | |
Modernizr.addTest('hires', function() { | |
// starts with default value for modern browsers | |
var dpr = window.devicePixelRatio || | |
// fallback for IE | |
(window.screen.deviceXDPI / window.screen.logicalXDPI) || | |
// default value | |
1; | |
return !!(dpr > 1); | |
}); |
I'm also curious as to you use return !!(dpr > 1)
instead of just return dpr > 1
...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great idea – thanks! 😄
Just a curiosity – Why do you use
return !!(dpr > 1);
instead of justreturn dpr > 1;
? Are there any benefits?