If it's not in the DOM, then all you have to do is clear any JS links from it, and the garbage collector will delete it for you. This is essentially no different from a javascript object or javascript array. If you clear any links to it, the garbage collector will clear it.
So, if you create it like this:
var paragraphElement = document.createElement('p');
Then all you have to do to get rid of it is clear that the link:
var paragraphElement = null;
Without reference to the javascript element, the garbage collector will remove it.
source share