Skip to content

Instantly share code, notes, and snippets.

@martindrapeau
Created June 8, 2016 01:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martindrapeau/789c250bfcfda7407a681bf45ebde22f to your computer and use it in GitHub Desktop.
Save martindrapeau/789c250bfcfda7407a681bf45ebde22f to your computer and use it in GitHub Desktop.
var screenWidth = Math.max(window.screen.width * window.devicePixelRatio, window.innerWidth);
var factor = screenHeight >= 960 ? 2 : 1;
if (screenHeight >= 960*2) factor = 3;
if (screenHeight >= 960*2.5) factor = 4;
// Image urls are then modified to load the proper size:
imgUrl.replace(".png", factor + ".png");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment