Things are getting interesting...
In a multi-page application, tags are injected by Tag Manager and cleared on every page change/reload.
In a single page application, tags are injected and keep living in the DOM until a manual page reload.
I have just over 70 tags getting fired up on different dataLayer events. Tag Manager injects them all at the bottom of the DOM and they are never removed. If a user views many products, he will end up with hundreds of scripts tags and iFrames in the DOM. This seems to be causing serious memory leaks.
How can I prevent this? Is there something I don't understand using GTM in SPAs? I've searched but haven't found much information. Either people don't care about memory leaks or I'm doing something wrong.
Is there a way to clear all old script tags and iFrames so the garbage collector can do its job and free up some memory?
Thanks for your help, hopefully this thread can help more people facing the same problem as SPAs are getting more popular.