{"id":13496575,"url":"https://github.com/pmndrs/detect-gpu","last_synced_at":"2025-05-13T19:16:05.718Z","repository":{"id":38412852,"uuid":"142180965","full_name":"pmndrs/detect-gpu","owner":"pmndrs","description":"Classifies GPUs based on their 3D rendering benchmark score allowing the developer to provide sensible default settings for graphically intensive applications.","archived":false,"fork":false,"pushed_at":"2025-02-23T01:10:34.000Z","size":11631,"stargazers_count":1116,"open_issues_count":29,"forks_count":59,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-05-09T06:27:39.849Z","etag":null,"topics":["adaptive","babylonjs","benchmarks","browser","demo","detection","device","gpu","hardware","pixijs","progressive-enhancement","threejs","webgl","webgl2"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/pmndrs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-07-24T15:51:14.000Z","updated_at":"2025-05-06T08:57:19.000Z","dependencies_parsed_at":"2024-01-23T22:09:00.336Z","dependency_job_id":"4d510342-ff0e-40dd-b270-46c659f15117","html_url":"https://github.com/pmndrs/detect-gpu","commit_stats":{"total_commits":678,"total_committers":16,"mean_commits":42.375,"dds":0.4247787610619469,"last_synced_commit":"9b71b025f7e2e7283a0eedf6ad86b3983abdbce9"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmndrs%2Fdetect-gpu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmndrs%2Fdetect-gpu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmndrs%2Fdetect-gpu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmndrs%2Fdetect-gpu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pmndrs","download_url":"https://codeload.github.com/pmndrs/detect-gpu/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253568657,"owners_count":21928906,"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","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":["adaptive","babylonjs","benchmarks","browser","demo","detection","device","gpu","hardware","pixijs","progressive-enhancement","threejs","webgl","webgl2"],"created_at":"2024-07-31T19:01:51.983Z","updated_at":"2025-05-13T19:16:05.654Z","avatar_url":"https://github.com/pmndrs.png","language":"TypeScript","readme":"# Detect GPU\n\n[![npm version](https://badge.fury.io/js/detect-gpu.svg)](https://badge.fury.io/js/detect-gpu)\n[![gzip size](https://img.badgesize.io/https:/unpkg.com/detect-gpu/dist/detect-gpu.esm.js?compression=gzip)](https://unpkg.com/detect-gpu)\n[![install size](https://packagephobia.now.sh/badge?p=detect-gpu)](https://packagephobia.now.sh/result?p=detect-gpu)\n\nClassifies GPUs based on their 3D rendering benchmark score allowing the developer to provide sensible default settings for graphically intensive applications. Think of it like a user-agent detection for the GPU but more powerful.\n\n## Demo\n\n[Live demo](https://pmndrs.github.io/detect-gpu/)\n\n## Installation\n\nBy default we use the [UNPKG](https://unpkg.com) CDN to host the benchmark data. If you would like to serve the benchmark data yourself download the required benchmarking data from [benchmarks.tar.gz](https://github.com/pmndrs/detect-gpu/raw/master/benchmarks.tar.gz) and serve it from a public directory.\n\nMake sure you have [Node.js](http://nodejs.org/) installed.\n\n```sh\n $ npm install detect-gpu\n```\n\n## Usage\n\n```ts\nimport { getGPUTier } from 'detect-gpu';\n\n(async () =\u003e {\n  const gpuTier = await getGPUTier();\n\n  // Example output:\n  // {\n  //   \"tier\": 1,\n  //   \"isMobile\": false,\n  //   \"type\": \"BENCHMARK\",\n  //   \"fps\": 21,\n  //   \"gpu\": \"intel iris graphics 6100\"\n  // }\n})();\n```\n\n`detect-gpu` uses rendering benchmark scores (framerate, normalized by resolution) in order to determine what tier should be assigned to the user's GPU. If no `WebGLContext` can be created, the GPU is blocklisted or the GPU has reported to render on less than `15 fps` `tier: 0` is assigned. One should provide a fallback to a non-WebGL experience.\n\nBased on the reported `fps` the GPU is then classified into either `tier: 1 (\u003e= 15 fps)`, `tier: 2 (\u003e= 30 fps)` or `tier: 3 (\u003e= 60 fps)`. The higher the tier the more graphically intensive workload you can offer to the user.\n\n## API\n\n```ts\ngetGPUTier({\n  /**\n   * URL of directory where benchmark data is hosted.\n   *\n   * @default https://unpkg.com/detect-gpu@{version}/dist/benchmarks\n   */\n  benchmarksURL?: string;\n  /**\n   * Optionally pass in a WebGL context to avoid creating a temporary one\n   * internally.\n   */\n  glContext?: WebGLRenderingContext | WebGL2RenderingContext;\n  /**\n   * Whether to fail if the system performance is low or if no hardware GPU is\n   * available.\n   *\n   * @default false\n   */\n  failIfMajorPerformanceCaveat?: boolean;\n  /**\n   * Framerate per tier for mobile devices.\n   *\n   * @defaultValue [0, 15, 30, 60]\n   */\n  mobileTiers?: number[];\n  /**\n   * Framerate per tier for desktop devices.\n   *\n   * @defaultValue [0, 15, 30, 60]\n   */\n  desktopTiers?: number[];\n  /**\n   * Optionally override specific parameters. Used mainly for testing.\n   */\n  override?: {\n    renderer?: string;\n    /**\n     * Override whether device is an iPad.\n     */\n    isIpad?: boolean;\n    /**\n     * Override whether device is a mobile device.\n     */\n    isMobile?: boolean;\n    /**\n     * Override device screen size.\n     */\n    screenSize?: { width: number; height: number };\n    /**\n     * Override how benchmark data is loaded\n     */\n    loadBenchmarks?: (file: string) =\u003e Promise\u003cModelEntry[]\u003e;\n  };\n})\n```\n\n## Support\n\nSpecial care has been taken to make sure all browsers that support `WebGL` are also supported by `detect-gpu` including `IE 11`.\n\n## Changelog\n\n[Changelog](CHANGELOG.md)\n\n## Licence\n\nMy work is released under the [MIT license](https://raw.githubusercontent.com/pmndrs/detect-gpu/master/LICENSE).\n\n`detect-gpu` uses both mobile and desktop benchmarking scores from [https://gfxbench.com](https://gfxbench.com).\n","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmndrs%2Fdetect-gpu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpmndrs%2Fdetect-gpu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmndrs%2Fdetect-gpu/lists"}