An easy way to get the device pixel ratio of a screen using JavaScript.
Latest commit 9e059fc Aug 12, 2013 @tysonmatanich Merge pull request #1 from lencioni/bower
Add bower.json
Failed to load latest commit information.
.gitattributes Adding v1 Nov 6, 2012
.gitignore Adding v1 Nov 6, 2012 Adding URL to readme Nov 16, 2012
bower.json Add bower.json Aug 7, 2013
getDevicePixelRatio-min.js Adding v1 Nov 6, 2012
getDevicePixelRatio.js Adding v1 Nov 6, 2012


Allows you to get the device pixel ratio using JavaScript.

Size and delivery

Currently, getDevicePixelRatio.js compresses to around 318 bytes (~0.3 KB), after minify and gzip. To minify, you might try these online tools: [Microsoft Ajax Minifier]:(, [Uglify]:(, [Yahoo Compressor]:(, or Closure Compiler. Serve with gzip compression.


<script type="text/javascript">
	var devicePixelRatio = window.getDevicePixelRatio();


GetDevicePixelRatio supports a broad range of browsers and devices (there are currently no known unsupported browsers).