Before you add it to the page, you can add an error handler:
Then kick it off…
If you’re trying to detect this from
<script> tags in the HTML, you can still get a reference to it the script element, but you’d have to get that reference before it tries to execute to catch the error, so whatever, do that if you want.
If the script is blocked, you’ll probably get some message like this in the console:
That’ll throw that
onerror and you’ll be in a position to track it or respond to it if you want.
The trick on tracking is that you’ll want to use an analytics situation that won’t also be blocked. So if you’re hoping to send an event to Google Analytics or something, well, that’s not going to work very well.