Skip to content

An easy way to get the actual pixel width of a screen using JavaScript.

Notifications You must be signed in to change notification settings

tysonmatanich/GetDevicePixelWidth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GetDevicePixelWidth

Allows you to get the physical pixel width of a device using JavaScript.

Note: GetDevicePixelWidth includes [GetDevicePixelRatio]:(http://github.com/tysonmatanich/GetDevicePixelRatio)

Size and delivery

Currently, getDevicePixelWidth.js compresses to around 450 bytes (~0.4 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 devicePixelWidth = window.getDevicePixelWidth();
</script>

If you want to assume that the user is in landscape mode use the following:

<script type="text/javascript">
	var devicePixelWidth = window.getDevicePixelWidth(true);
</script>

Support

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

About

An easy way to get the actual pixel width of a screen using JavaScript.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published