CKTIS / JavaScript
IntersectionObserver.unobserve — stop observing one element
The unobserve(target) method stops a particular IntersectionObserver from observing the specified element, leaving its other targets unchanged. It does not remove notifications that are already queued.
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.unobserve(target)IntersectionObserver.unobserve is an instance method called as observer.unobserve(target). The target argument must be an Element, not a selector. The method returns undefined; calling it again for an unobserved element changes nothing.
unobserve(target) detaches only the specified element from this observer. disconnect() detaches all its targets. A later observe(target) can start observation again. A typical use is stopping tracking after loading content once.
Notifications are asynchronous: unobserve(target) does not remove entries already queued or entries passed to a running callback. takeRecords() retrieves and empties the observer's entire queue, not just entries for that element.
This is a browser Web API, not a feature of a particular ECMAScript edition. Check availability in the target browser; Node 24 in the repository does not establish support. The example synchronously starts and stops observation of a detached element, without depending on scrolling.
Examples
(() => {
const target = document.createElement('div');
const observer = new IntersectionObserver(() => {
console.log('unexpected callback');
});
observer.observe(target);
console.log(observer.unobserve(target) === undefined);
console.log(observer.unobserve(target) === undefined);
console.log(observer.takeRecords().length);
observer.disconnect();
})();Result
true true 0
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.