Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1541

Dynamically injected script execution not working on page navigation using

$
0
0

In my test application using Sveltekit, I tried to inject third party scripts to page using

<script>     let scriptsData = 'console.log("Some script executed")';   </script><svelte:head>     {@html        `<script>${scriptsData}</script>`         }  </svelte:head>

The above code works fine on direct hit of the page but not during manual navigation to the page. The same thing work if I use

<svelte:head> <script>console.log("Some script executed")</script>`     </svelte:head>

But I wish to add scripts dynamically per page. I read somewhere that browser for safety reasons will not execute scripts added dynamically. It accepts only sanitised one's.Is there any easy workaround


Viewing all articles
Browse latest Browse all 1541

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>