Skip to content

Instantly share code, notes, and snippets.

@dmacompton
Created February 4, 2016 15:30
Show Gist options
  • Select an option

  • Save dmacompton/5331ae1bfea1b2f6bb23 to your computer and use it in GitHub Desktop.

Select an option

Save dmacompton/5331ae1bfea1b2f6bb23 to your computer and use it in GitHub Desktop.

Revisions

  1. dmacompton created this gist Feb 4, 2016.
    13 changes: 13 additions & 0 deletions isRetina.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    isRetina = function(){
    var mediaQuery = '(-webkit-min-device-pixel-ratio: 1.5), (min--moz-device-pixel-ratio: 1.5), (-o-min-device-pixel-ratio: 3/2), (min-resolution: 1.5dppx)';
    var root = (typeof exports === 'undefined' ? window : exports);
    if (root.devicePixelRatio > 1) {
    return true;
    }

    if (root.matchMedia && root.matchMedia(mediaQuery).matches) {
    return true;
    }

    return false;
    };