{"id":16760364,"url":"https://github.com/ryanve/res","last_synced_at":"2025-08-02T09:35:56.885Z","repository":{"id":10688250,"uuid":"12928830","full_name":"ryanve/res","owner":"ryanve","description":"Device resolution detection module","archived":false,"fork":false,"pushed_at":"2016-09-12T00:32:18.000Z","size":28,"stargazers_count":39,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-21T23:55:16.779Z","etag":null,"topics":["dpcm","dpi","dppx","javascript","resolution"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/res","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ryanve.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-09-18T16:51:42.000Z","updated_at":"2024-07-18T11:19:05.000Z","dependencies_parsed_at":"2022-09-26T17:50:31.351Z","dependency_job_id":null,"html_url":"https://github.com/ryanve/res","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/ryanve/res","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Fres","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Fres/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Fres/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Fres/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryanve","download_url":"https://codeload.github.com/ryanve/res/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Fres/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268363001,"owners_count":24238545,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dpcm","dpi","dppx","javascript","resolution"],"created_at":"2024-10-13T04:23:16.142Z","updated_at":"2025-08-02T09:35:56.833Z","avatar_url":"https://github.com/ryanve.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# res\n[CSS resolution](http://www.w3.org/TR/css3-values/#resolution) detection in JavaScript\n\n```sh\nnpm install res --save\n```\n\n## API\n\n\u003ca name=\"dpi\"\u003e\u003c/a\u003e\n### `res.dpi()`\n- Get resolution in [dpi](http://www.w3.org/TR/css3-values/#dpi)\n- \u003cb\u003e@return\u003c/b\u003e number\n\n\u003ca name=\"dpcm\"\u003e\u003c/a\u003e\n### `res.dpcm()`\n- Get resolution in [dpcm](http://www.w3.org/TR/css3-values/#dpcm)\n- \u003cb\u003e@return\u003c/b\u003e number\n\n\u003ca name=\"dppx\"\u003e\u003c/a\u003e\n### `res.dppx()`\n- Get resolution in [dppx](http://www.w3.org/TR/css3-values/#dppx)\n- \u003cb\u003e@return\u003c/b\u003e number\n\n## Usage\n\n```js\nvar res = require('res')\nres.dppx() // 1\nres.dpi() // 96\nres.dpcm() // 37.79527559055118\n```\n\n### Technical notes\n- [dppx](http://www.w3.org/TR/css3-values/#dppx) equals [`devicePixelRatio`](http://dev.w3.org/csswg/cssom-view/#dom-window-devicepixelratio)\n- [dppx](http://www.w3.org/TR/css3-values/#dppx) is the preferred resolution unit for web design\n- [User zoom affects resolution](../../issues/1)\n\n### Use with care\n\u003cb\u003eres\u003c/b\u003e was mainly written for [investigative](http://ryanve.com/lab/resolution/) purposes. Making [retina](../../issues/2#issuecomment-41459302) design accommodations can be impractical. Consider alternatives to resolution detection.\n\n### Example outputs\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003cth scope=\"col\"\u003eDevice\u003c/th\u003e\n    \u003cth scope=\"col\"\u003e\u003ccode\u003eres.ddpx()\u003c/code\u003e\u003c/th\u003e\n    \u003cth scope=\"col\"\u003e\u003ccode\u003eres.dpi()\u003c/code\u003e\u003c/th\u003e\n    \u003cth scope=\"col\"\u003e\u003ccode\u003eres.dpcm()\u003c/code\u003e\u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003edesktop at default zoom\u003c/td\u003e\n    \u003ctd\u003e1\u003c/td\u003e\n    \u003ctd\u003e96\u003c/td\u003e\n    \u003ctd\u003e37.79527559055118\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eiPhone 4s at default zoom\u003c/td\u003e\n    \u003ctd\u003e2\u003c/td\u003e\n    \u003ctd\u003e192\u003c/td\u003e\n    \u003ctd\u003e75.59055118110236\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n## Compatibility\n#### Browsers with resolution detectable by \u003cb\u003eres\u003c/b\u003e\n\n- Webkit (Chrome/Safari/Android)\n- Firefox 18+\n- Opera 11.1+ (Presto 2.8+)\n- IE 6+\n\n**Methods return `0` where undetectable.**\n\n## Related resources\n- [actual](https://github.com/ryanve/actual)\n- [CSS4 resolution](http://dev.w3.org/csswg/mediaqueries4/#resolution)\n- [CSS3 resolution](http://w3.org/TR/css3-values/#resolution) and [units](http://w3.org/TR/css3-values/#absolute-lengths)\n- [Demo media queries](http://ryanve.com/lab/@media/#mq-resolution)\n- [Resolution lab](http://ryanve.com/lab/resolution/)\n\n## License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanve%2Fres","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryanve%2Fres","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanve%2Fres/lists"}