0

So on my website, I integrated a plugin called manychat. This is implemented by a <script>;

When I click on the Drawer Cart this manychat symbol overlays over the checkout button, which doesn't look nice.

So when I click the "cart" button it should unload this script. With the next action, it should then be loaded again.

Is this possible?

I am using Shopify

<script src="//widget.manychat.com/1541935499435047.js" async="async"></script>

Charlie
  • 22,886
  • 11
  • 59
  • 90
  • This is an X/Y problem. Move or hide the buttons using CSS – mplungjan Jul 11 '19 at 08:03
  • once you load a script into the browser, it has free reign of the environment and you can't tell what side effects it's had, nor how to undo them - it could load more scripts, change styles, etc. Unless built in to the script, there's no official way of canceling the side effects of a script. – Yaelet Jul 11 '19 at 08:14

1 Answers1

0

You can't unload a script once loaded. You can, however, dig deep in to the script and cancel out the global variables it create - and undo what it does to your DOM such as any event listeners it might have registered.

Charlie
  • 22,886
  • 11
  • 59
  • 90
  • Could you maybe explain a little bit more on how this works? – Fabian Gmeindl Jul 11 '19 at 10:44
  • The library you load must be setting event listners, global functions etc. Removing all the effects of the library means undoing all these. Please have a look at this answer which I wrote today: https://stackoverflow.com/a/56984379/4185234 – Charlie Jul 11 '19 at 10:54