CKTIS / JavaScript
ResizeObserver.disconnect() — stop all observations
The disconnect() method stops observing every element registered with one ResizeObserver instance. It does not destroy the observer: observe() can start observation again.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
observer.disconnect()observer.disconnect() takes no arguments and returns undefined. It clears this instance’s observed-element list and active observations. Unlike unobserve(target), it removes all observations, not just one.
Call it during component cleanup. Calling it again is safe; you can subsequently use observe(target). It does not interrupt an already executing callback.
The example disconnects after the first notification, then changes the width. Expect one entries: 1 message. This browser API is specified in Resize Observer Module Level 1, not ECMAScript; a Node 24 environment does not establish browser availability.
Examples
(() => {
const box = document.createElement('div');
box.style.cssText = 'width:100px;height:20px;';
document.body.append(box);
const observer = new ResizeObserver((entries) => {
console.log('entries:', entries.length);
observer.disconnect();
box.style.width = '200px';
requestAnimationFrame(() => box.remove());
});
observer.observe(box);
})();Result
entries: 1
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.