{"id":19533944,"url":"https://github.com/rafgraph/detect-passive-events","last_synced_at":"2025-05-12T03:31:38.340Z","repository":{"id":57212005,"uuid":"73219792","full_name":"rafgraph/detect-passive-events","owner":"rafgraph","description":"Detect if the browser supports passive event listeners","archived":false,"fork":false,"pushed_at":"2021-02-12T00:58:02.000Z","size":1003,"stargazers_count":39,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-05T23:38:32.823Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://detect-it.rafgraph.dev","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/rafgraph.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":"2016-11-08T19:27:26.000Z","updated_at":"2023-03-13T01:50:06.000Z","dependencies_parsed_at":"2022-09-08T21:12:04.642Z","dependency_job_id":null,"html_url":"https://github.com/rafgraph/detect-passive-events","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafgraph%2Fdetect-passive-events","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafgraph%2Fdetect-passive-events/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafgraph%2Fdetect-passive-events/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafgraph%2Fdetect-passive-events/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rafgraph","download_url":"https://codeload.github.com/rafgraph/detect-passive-events/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253668046,"owners_count":21944967,"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":[],"created_at":"2024-11-11T02:11:16.317Z","updated_at":"2025-05-12T03:31:37.971Z","avatar_url":"https://github.com/rafgraph.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Detect Passive Events\n\nDetects if the browser supports passive event listeners. Tree-shakable and side-effect free. Also available as part of [`detect-it`][detectitrepo].\n\n[Live detection test][livedetectiontest]\n\n[![npm](https://img.shields.io/npm/dm/detect-passive-events?label=npm)](https://www.npmjs.com/package/detect-passive-events) [![npm bundle size](https://img.shields.io/bundlephobia/minzip/detect-passive-events?color=purple)](https://bundlephobia.com/result?p=detect-passive-events) ![npm type definitions](https://img.shields.io/npm/types/detect-passive-events?color=blue)\n\n\u003e Note that the code used in the detection is adapted from this [Passive Events Explainer][passiveexplainer].\n\n### Using `detect-passive-events`\n\n```\nnpm install --save detect-passive-events\n```\n\n```js\n// supportsPassiveEvents is a boolean\nimport { supportsPassiveEvents } from 'detect-passive-events';\n\nif (supportsPassiveEvents) {\n  // passive events are supported by the browser\n  document.addEventListener('scroll', handleScroll, { capture: false, passive: true });\n} else {\n  // passive events are not supported by the browser\n  document.addEventListener('scroll', handleScroll, false);\n}\n```\n\n### Or use the script directly in the browser\n\nOptionally, instead using `npm install` you can the load the script directly in the browser. A minified UMD version is available from Unpkg for this purpose.\n\n```html\n\u003cscript src=\"https://unpkg.com/detect-passive-events@2/dist/detect-passive-events.umd.production.js\"\u003e\u003c/script\u003e\n```\n\n```js\n// it will be available on the window as DetectPassiveEvents\nif (window.DetectPassiveEvents.supportsPassiveEvents) {\n  document.addEventListener('scroll', handleScroll, { capture: false, passive: true });\n} else {\n  document.addEventListener('scroll', handleScroll, false);\n}\n```\n\n\u003c!-- links --\u003e\n\n[livedetectiontest]: https://detect-it.rafgraph.dev\n[passiveexplainer]: https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md\n[detectitrepo]: https://github.com/rafgraph/detect-it\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frafgraph%2Fdetect-passive-events","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frafgraph%2Fdetect-passive-events","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frafgraph%2Fdetect-passive-events/lists"}