
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
Easy and universal way to react to elements being `disconnected` and `connected` via native DOM events.
npm: npm i disco
cdn: https://unpkg.com/disco
Easy and universal way to react to elements being disconnected and connected via native DOM events.
Observe via a direct node reference, an array of nodes or a string selector that internally makes use of Element.matches(selectorString). It's recommended to keep the observed scope as small as possible for the best performance.
import { observe } from 'disco';
/**
* Observe one specific div element
*/
const div = document.createElement('div');
observe(div);
div.addEventListener('connected', () => console.log('connected!'));
document.body.append(div);
/******************************************************************/
/**
* Observe all (future) h1 elements.
*/
observe('h1');
const firstH1 = document.createElement('h1');
const lastH1 = document.createElement('h1');
firstH1.addEventListener('connected', () => console.log('connected!'));
lastH1.addEventListener('connected', () => console.log('connected!'));
document.body.append(firstH1, lastH1);
/******************************************************************/
/**
* Observe all section elements in the document for removal.
*/
const sections = document.querySelectorAll('section');
observe(...sections);
[...sections].forEach(section =>
section.addEventListener('disconnected', () => console.log('🕺')))
Observe a node, array of nodes or an element selector for dis-connected events.
Unobserve for dis-connected events.
Observe a node, array of nodes or an element selector for dis-connected events.
Kind: global function
| Param | Type |
|---|---|
| ...nodesOrSelectors | Node | String |
Unobserve for dis-connected events.
Kind: global function
| Param | Type |
|---|---|
| [...nodesOrSelectors] | Node | String |
FAQs
Easy and universal way to react to elements being `disconnected` and `connected` via native DOM events.
The npm package disco receives a total of 15 weekly downloads. As such, disco popularity was classified as not popular.
We found that disco demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.