JSPM

javascript-retina-detect

0.1.4
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 170
  • Score
    100M100P100Q86438F
  • License MIT

Javascript detect retina screen (javascript detect device pixel ratio / density)

Package Exports

  • javascript-retina-detect

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (javascript-retina-detect) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

javascript-retina-detect

[![NPM Version][npm-badge]][npm] [![Build Status][travis-badge]][travis] [![Test Coverage][coveralls-badge]][coveralls]

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 --save

Usage

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 install

This module is written in ES6 and uses Babel for ES5 transpilation. Widely consumable JavaScript can be produced by running:

npm run build

Once 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 test

While actively developing, one can use (personally I don't use it)

npm run watch

in 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 pack

It 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

License

MIT [npm]: https://www.npmjs.org/package/javascript-retina-detect [npm-badge]: https://img.shields.io/npm/v/javascript-retina-detect.svg?style=flat-square [travis]: https://travis-ci.org/halt-hammerzeit/javascript-retina-detect [travis-badge]: https://img.shields.io/travis/halt-hammerzeit/javascript-retina-detect/master.svg?style=flat-square [coveralls]: https://coveralls.io/r/halt-hammerzeit/javascript-retina-detect?branch=master [coveralls-badge]: https://img.shields.io/coveralls/halt-hammerzeit/javascript-retina-detect/master.svg?style=flat-square