Disclaimer: This website requires Please enable JavaScript in your browser settings for the best experience.

The availability of features may depend on your plan type. Contact your Customer Success Manager if you have any questions.

Dev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideLegal TermsGitHubDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Reset JS

How to use the Reset JS code section of the Template Builder for Optimizely Web Experimentation and Optimizely Personalization

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 the extension.$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();