I (as many others do) use an ad blocker.
Recently I visited a website that detected I was using an ad blocker and hid the content from me.
However, it did interest me as to how it was achieved and as it transpires the technique is quite simple.
Firstly create a file called
In your html file then you could have something like;
The technique is simple.
Load advert.js. If it does load then __sneaky_adverts will be true (!undefined). If it fails then the
if will fire.
You may ask why I am using a window.onload event though.
I advocate speed. I don’t want advert.js to render block so I am loading it asynchronously. That means I have to give the browser enough time to load the file before I check for __sneaky_adverts :)
Like this post? Share it :)