As the question states, what I’m attempting to do is have a function that is called when a DOM element is removed from the DOM, much like a destructor.
I looked into unload, but from my understanding that’s only called when the browser navigates away from the page.
Thanks in advance!
I don’t know if it’s that what you’re looking for. Not really pretty code, just to show what I would like to use:
There are of course solutions based on watching the DOM directly but the problem is the browser compatibility. You should probably check out mutation events.