There is no 100% technique, but there are some recommended:
Checking the size of an element
function detectAddNotLoaded() {
if ($('.foo_dd').height() == 0) {
// Aqui vc toma a decisão. Mostrar um aviso, redirecionar, etc...
}
}
$(document).ready(function(){
detectAddNotLoaded();
});
<div class="foo_dd"><script>
//aqui deve mostrar um banner, mas o adblock bloqueia.
//A ideia é verificar a altura. Se for ZERO, possivelmente não foi carregado devido ao adblock
</script></div>
<div class="foo_dd"><script>
//aqui deve mostrar um outro banner
</script></div>
Against: A user without adblock enters the page and the banners may not load due to an eventual failure or may take a long time to load.
The advantage over the next example is that it becomes more consistent against more sophisticated blockers that do not block files by nomenclature (ads.js, .js, etc.)
Loading a locked file
The technique is to load a url whose name is blocked by the blockers.
The logic is, the ajax request will fail because the blocker will prevent access to "/js/ads.js".
$.ajax({
url: "/js/ads.js",
dataType: "script"
})
.fail(function () {
// Aqui vc toma a decisão. Mostrar um aviso, redirecionar, etc...
});
The ads.js file may be empty.
Blockers typically seek to block anything that is named ads.js, advertisement.js, and related names. So that's the logic.
Contra: The ajax request may fail for N reasons. Think of the user who has no blocker and then the ajax happens to fail.
Considerations
For both examples, the contra points have a small probability of combinations.
The above examples are not definitive solutions, nor do they claim this. Be aware that there are other ways to solve (read "get as close as you can to the desirable"). Blockers change the algorithms periodically to fit the market just as the ads also fit the market and seek to protect themselves from blockers. It is a constant "war".
Finally, which decision to make depends on each case.
Evaluate the pros and cons for your case.