CKTIS / JavaScript
IntersectionObserver.observe — start observing an element
The observe(target) method registers an element for asynchronous intersection tracking against root, using the observer's configuration.
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.observe(target)observer.observe(target) accepts an Element and returns undefined. Registering the same element again does nothing. One observer can track multiple elements; configure root, rootMargin, and threshold in the constructor, not in observe().
When the browser first evaluates the registered target, it queues an initial entry even if there is no intersection. Queued entries are delivered to the callback asynchronously, but the callback may not receive that initial entry: unobserve(target) can stop observation before the entry is generated, and takeRecords() can remove it from the queue before delivery. A threshold crossing or a change in isIntersecting can queue a later entry. The callback receives an array of entries. Geometric intersection does not prove actual pixel visibility.
unobserve(target) stops tracking one element; disconnect() stops all. This is a browser Web API, not a feature of a particular ECMAScript edition; check availability in the target environment. Node 24 alone does not establish support.
Examples
(() => {
if (!("IntersectionObserver" in window)) {
throw new Error("IntersectionObserver is unavailable");
}
const target = document.createElement("div");
target.style.display = "none";
document.body.append(target);
const observer = new IntersectionObserver((entries) => {
console.log("initial:", entries[0].isIntersecting);
observer.disconnect();
target.remove();
});
observer.observe(target);
observer.observe(target);
console.log("started");
})();Result
started initial: false
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.