Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 73875

How to remove script tag depending on the reactjs router?

$
0
0

I've integrated a third-party chatbot with the help of script tag in the public/index.html. But on some urls I don't want to show the chatbot at all.

How can I remove the script tag depending on the url before/after it loads.

public/index.html:

<body>
      <div id="root"></div>

      <script type="text/javascript">
        var Tawk_API=Tawk_API||{}, Tawk_LoadStart=new Date();
        (function(){
        var s1=document.createElement("script"),s0=document.getElementsByTagName("script")[0];
        s1.async=true;
        s1.src='https://embed.tawk.to/<TOKEN_ID>/default';
        s1.charset='UTF-8';
        s1.setAttribute('crossorigin','*');
        s0.parentNode.insertBefore(s1,s0);
        })();
      </script>

    </body>

Viewing all articles
Browse latest Browse all 73875

Trending Articles



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