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.
The most popular content blocking lists are EasyList, for ads, and EasyPrivacy, for general privacy-invasive things* like Appcues. https://easylist.to/
EasyPrivacy is notably enabled by default in uBlock Origin. People using a lesser “ad block” generally only benefit from EasyList.
They have a broad definition of “privacy-invasive”, my own instant.page is blocked by EasyPrivacy because webmasters could otherwise theoretically infer mouse movements by looking at server logs.