Lifecycle and destroy
When AI Try-On loads, what happens when the shopper closes it and how to remove it in a single-page app.
AI Try-On adds one dialog to your page the first time it opens. With a script tag or JavaScript, closing it removes the dialog, and the next opening starts afresh with the product of the button pressed.
The shopper's past try-ons, including their photos, and the photo tips they have seen are kept in your site's browser storage (IndexedDB vizbl-ai-try-on and localStorage keys starting with vizbl), so a shopper who comes back finds their results.
In a single-page app, remove AI Try-On when its trigger leaves the page, so a dialog from one route does not stay behind on the next.
The embed build serves the whole page: it listens to clicks on the document, so triggers added later work, and you never bind or unbind them. It stays for the life of the page.
To remove AI Try-On when a route changes, use the JavaScript package: new AiTryOnDialog() gives you destroy().