How can I make sure a script that I add to my website fails silently?

Viewed 26

I add a script to my website, however when it cannot be loaded, it pops up a warning saying something was not loaded, and does this each time I change the route. It's an angular application if it changes anything.

Here's how i add the script:

var script = document.createElement('script');
script.setAttribute('async', '');
script.setAttribute('defer', '');
script.setAttribute('src', '...');
script.setAttribute('onerror', ''); // tried this
document.getElementsByTagName('head')[0].appendChild(script);

I tries to set its onerror attribute to null as so, but this doesn't help.

0 Answers
Related