diff --git a/src/components/AdSlot/AdSlot.svelte b/src/components/AdSlot/AdSlot.svelte index fc47239c..5ebcf2fc 100644 --- a/src/components/AdSlot/AdSlot.svelte +++ b/src/components/AdSlot/AdSlot.svelte @@ -39,7 +39,25 @@ window.graphicsAdQueue = window.graphicsAdQueue || []; window.graphicsAdQueue.push(adSlot); } + + return () => { + // @ts-ignore + const freestar = window?.freestar; + if (freestar) { + freestar.queue.push(function () { + freestar.deleteAdSlots(adId); + }); + } + }; });
+ + diff --git a/src/components/AdSlot/adScripts/loadScript.ts b/src/components/AdSlot/adScripts/loadScript.ts index 08895a2e..72907a73 100644 --- a/src/components/AdSlot/adScripts/loadScript.ts +++ b/src/components/AdSlot/adScripts/loadScript.ts @@ -6,6 +6,9 @@ interface attributesInterface { export const loadScript = (src: string, attributes?: attributesInterface) => { const { onload, async = true } = attributes || {}; + const existingScript = document.querySelector(`script[src="${src}"]`); + if (existingScript) return; + const script = document.createElement('script'); script.addEventListener('load', onload); script.async = async;