Detect that given element has been removed from the DOM without sacrificing performance
问题 I've got these: const element = this.getElementById("victim") function releaseKraken(targetElement) {} I want the function to be called when element is removed from DOM. I can imagine something like this: element.onRemove(() => releaseKraken(element)) I understand that I need MutationObserver , but all the documentation I found focuses on watching given element's children, whereas I need to watch the element itself. UPD: the question How to detect element being added/removed from dom element?