javascript-retina-detect v0.1.4
javascript-retina-detect
Detects device screen pixel ratio programmatically (through javascript). Using this tool one can decide whether to fetch retina images or save bandwidth (and power) and fetch normal resolution images.
Installation
npm install javascript-retina-detect --saveUsage
import { device_pixel_ratio } from 'javascript-retina-detect'
device_pixel_ratio()
// `1` for normal screens
// `2` for retina@2x
// `3` for retina@3x
// …Contributing
After cloning this repo, ensure dependencies are installed by running:
npm installThis module is written in ES6 and uses Babel for ES5 transpilation. Widely consumable JavaScript can be produced by running:
npm run buildOnce npm run build has run, you may import or require() directly from
node.
After developing, the full test suite can be evaluated by running:
npm testWhile actively developing, one can use (personally I don't use it)
npm run watchin a terminal. This will watch the file system and run tests automatically whenever you save a js file.
When you're ready to test your new functionality on a real project, you can run
npm packIt will build, test and then create a .tgz archive which you can then install in your project folder
npm install [module name with version].tar.gz