const SCRIPT_ID = 'activity-flow-script' const SCRIPT_URL = 'https://activity-flow.vtex.com/af/bridges/af.js' let isScriptLoaded = false /** * Loads the Activity Flow script into the document head. * This function is idempotent - calling it multiple times will only load the script once. */ export function loadActivityFlowScript() { if (isScriptLoaded) return if (document.getElementById(SCRIPT_ID)) { isScriptLoaded = true return } const script = document.createElement('script') script.id = SCRIPT_ID script.src = SCRIPT_URL script.async = true document.head.appendChild(script) isScriptLoaded = true }