Use Reset JS to "clean up" after an experience template in Optimizely Web Experimentation and Optimizely Personalization. Use it in the editor when changing field values or removing an existing template. Reset JS should remove the element and any other side effects.
One way to write reset JS is to use theextension.$instance value. For example, you could create a template with HTML.
<div class="banner" data-extension-instance="{{extension.$instance}}">
You can then remove it using Reset JS.
$("[data-extension-instance=" + extension.$instance + "]").remove();