Skip to content
An easy way to get the device pixel ratio of a screen using JavaScript.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitattributes
.gitignore
README.md
bower.json
getDevicePixelRatio-min.js
getDevicePixelRatio.js

README.md

GetDevicePixelRatio

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]:(http://ajaxmin.codeplex.com/), [Uglify]:(http://marijnhaverbeke.nl/uglifyjs), [Yahoo Compressor]:(http://refresh-sf.com/yui/), or Closure Compiler. Serve with gzip compression.

Sample

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

Support

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

You can’t perform that action at this time.