I created a section in Shopify where the JavaScript needs to re-render every time the user makes changes. One thing I don’t fully understand is that when the JS is re-rendered, the old event listeners stack with the new ones. Here’s a minimal example: <script> document.addEventListener( 'DOMContentLoaded', function() { console.log("Shows in live") }); if (Shopify.designMode) { document.addEventListener('shopify:section:load', function(event) {...
Originally asked by Liam on Stack Exchange (stackoverflow) (CC BY-SA 4.0).