How to Keep AdBlock From Hiding Your Ads

One of Firefox’s more popular extensions is AdBlock Plus, an add-on that can stop ads from showing as you browse the web. There are two ways to use it. You can selectively kill ads that are so annoying that you can’t stand them (e.g. the ones that float over content or play audio), or you can install a filter subscription that will automatically block any ads that fit the extensive criteria.

Now I like AdBlock, don’t get me wrong. I use it selectively, to remove ads that I find offensive or that hinder my use of a site too much. However, I don’t blanket-block ads like many people do. Why? Because the ads pay for the sites that produce free content for my consumption. I don’t like the flashing “Click here for a free iPod” ads any more than anyone else, but not all ads are like them. There are some ads that just sit there quietly, promoting a product that I don’t mind being shown. Those ads, the reasonable ones, are the way ads should be. They benefit the site, the advertiser, and ideally the reader. AdBlock only came into existence because of the annoying ads, the ones that give online advertising a bad name.

Imagine my indignation when I realized that the “EasyList + EasyElement” filter for AdBlock (one of the most popular filter subscriptions) was automatically blocking the 125×125 ads in my sidebar. I go through a lot to put those ads there. I work hard to make sure that they are unobtrusive, and I spend a fair bit of time communicating with companies to make ad deals. Not only does blocking them cheat the advertisers out of what they are paying for, it hurts my chances of them continuing to advertise.

I don’t mind AdBlock being used to zap less than pleasant ads…in fact, if you run obnoxious advertisements on your site, you’re asking to have them blocked. What are you thinking? If you would only run ads that don’t try your users’ patience, maybe you wouldn’t have to worry about people blocking them so much?

Now, I wasn’t going to let my ads be blocked so easily. No, I had to find a way to prevent them from being blocked.

So, I found the URL for the subscription, by opening up AdBlock, right-clicking the subscription, and choosing “Edit subscription.” I found the URL in the resulting dialog.

I found it at this URL. Now I had a text file containing a very long list of filter rules. Anything matching the criteria would generally be blocked.

Many of the rules were specific to certain websites and ad servers. There were certain ones that interested me, the ones that check for keywords in the page source, such as classes, ids, and image paths. The file was a bit terse, but not too hard to read.

The logical thing to do was to skim through it and make a list of words that I wanted to avoid having in my image URLs or in the ad elements’ ids and classes. Essentially, I wanted to avoid anything along the lines of ad, ad1, ad2, sponsors, affiliate, bannerad, or really anything that could be associated with advertising.

So I made some tweaks to the location of the ad images on my server, and I also switched over to my WP125 plugin to handle my ad management. Apparently it’s immune to the EasyList right out of the box, as long as you don’t make the mistake of having “/ads/” in the images’ paths. There’s no rule in the filter that will trip when it comes across a div with one of the classes used in WP125. (Even if there were, I could simply change the WP125 classes, since I develop the plugin…)

This would work potentially with any ad format. You just need to look at the filters carefully to see what might trigger them. There’s generally a workaround for most of them. Fortunately there aren’t any filter rules that respond to “any image with x width and y height,” as that would often block images that wouldn’t be considered advertisements. You just need to look through the list of rules, find out what to avoid, and optimize your ads accordingly.

The trick probably won’t work with ad networks though, since the ads are generally called by a bit of JavaScript pulled from a certain domain. If that ad server goes into the filter, you’re in for a bit more work than simple optimization. You’re going to have to use some JavaScript trickery to actually block AdBlock. You would want to wait until the page loads, then check to see if a specific DOM element is being displayed, then respond accordingly. You could write the ads back in, or you could simply reprimand the ad-blocking user. There’s a tutorial on how to do the check and display an alert() message, but if you want to use it to reinstate the ads, you’re going to have to figure that out for yourself. Personally, I would stick with creatively guilting the users into disabling AdBlock for my site, as there are some ramifications from actually putting the ads back in. (See the tutorial linked above.)

I’ve provided you with the tools to prevent your ads from being blocked, but please use them responsibly. I encourage you to carefully assess your ads before employing the techniques discussed above, and only use them if your ads truly are benign.

  • bob the mob

    Use text ads from your own domain, or don’t expect any revenue. Personally, I block ads because the site owner should be making an effort to seek out advertisers on their own. If you aren’t popular enough, or not capable of devoting the time required, too bad. That’s business. Ad networks are built on people too lazy to do their own work.

  • Chris

    I blocked all of your ads. I use adblock to block ads and sites that have them I don’t go to afterwords anyways. That may not effect them directly (I wasn’t seeing their ads to begin with), but I’ll definitely not send their link on to my adblock-less friends.

  • Matt

    @bob the mob, you have a point. I do just that though, I spend a lot of time making ad deals the hard way, and I have stringent guidelines for said ads. Needless to say I wasn’t happy when I found out that those ads hadn’t been showing for a lot of my readers. After fixing them so they would, the clickthrough rate increased to 3-5 times what it had been. I take that as a sign that they don’t mind the ads.

    @Chris, that sort of unreasonable opinion doesn’t merit a response other than “thanks for doing your part to hurt my main source of income.” I don’t walk into your place of employment and get you fired, do I?

  • minerva66

    Matt, good for you, and thanks for giving out the information.

    Bob the mob, there is nothing wrong with using a shortcut until you have enough viewers to have advertisers coming to you. It isn’t laziness. I find your reason for blocking ads silly. If they are unobtrusive, there is no real reason-just spitefulness.

    For all of those so set on blocking ads, consider this: many people would not be spending as much time putting content onto the web if they had no chance of gain from it. Personally, I have a full life and have cut back on other things in my life in order to post information. Obviously, money would not be my sole or even primary reason. But since it costs me both time and money to manage my site, it would be nice to get something back. The web is a fuller experience as a result of monetary gain from ads. If the ads are all blocked, you may see some of your favorite sites decreasing content or disappearing.

  • Chris

    No, but if I go into your place of opinion and you offer to help me and I say no thanks, then you repeatedly step in front of me to ask again I’m gonna be pretty annoyed and not come back to the store.

    I don’t see the opinion as unreasonable. I went out of my way to block ads that are completely unrelated to the content I was viewing and you know that and want to still push ads on me. Do you think that is the way to get return visitors? To recognize what they want and then battle to override it?

    The way to defeat ad-blocking is to reach your ad-blocking viewers in better ways, not to attempt to change them by force.

    The thing is, effective ad-blocking is still a relatively small segment of the average readership, the more technically inclined of course but not a huge group regardless.

    Annoying these people may not have a direct impact on your ad revenue, but you can be sure your site won’t grow by many thumbs up on stumble upon or get attention from sites like reddit or digg.

    I find ads that are definitely not content related to be obtrusive.

  • Matt

    @Chris, look at the ads on Webmaster-Source. There are unobtrusive and carefully moderated 125×125 ads, and a single AdSense block at the bottom of a post. This site is very light when it comes to ads, and I’m careful to make sure they are relevant.

    To continue your analogy, I am standing to the side of the room, waiting for you to approach me for help. Note that the ads are in the sidebar, where you can look at will.

    I’m not attempting to “change them by force.” I simply ensured that the filters would not automatically block the ads. You can still do it manually, as you just proved. I like ads that hover over content and play audio as much as you do, but I assure you there are no such ads here.

    Actually, at least 80% of this blog’s audience is “technically inclined,” and use AdBlock. Though since I tweaked the ads around, CTR has increased greatly, implying that those who had been inadvertently blocking the ads had started viewing and clicking them. That would imply that the ads are valuable to them, though they had been unaware of their presence due to AdBlock.

    I don’t care much about the AdSense…block those at will. It’s the 125×125 blocks that I really care about.

    Also, see minerva66’s comment above.

  • Thaya Kareeson

    Like many other sites, this site is funded by advertisements. By visiting this site you are implicitly agreeing to view advertisement in exchange for free content. Regardless of whether the advertisement is properly targetted or not, you agree to view them by coming to this site. Why cheat? Isn’t it fair for you to get FREE content for just viewing related advertisements. If you block ads why not pay a subscription fee to Webmaster Source?

  • Almir

    Hi Matt!

    Thank you for your solemn and well meaning article. I agree with most of it, reminds me of an analysis I wrote back in high school as part of an english test… where I choose to analyze online advertising and the pros and cons of their different types, their effects and so forth. Of course, that was just a test in linguistic proficiency.

    However, whilst your methods to avoid triggering the automatic filter works to a certain extent, it is still easily blockable by anyone who actively wants to. I think just like you, that if one has reasonable advertising, related to ones content, and by partners that suit ones readerbase, I dont think that the readers really mind that anymore than they understand the benefits of having such a rational and relevant partnership.

    I have only seen one site that successfully blocks Ad Block, and that is swedish . They do it by connecting the ads to the whole website presentation, so you cannot technically block the ads without also blocking the actual content.

    In other words, instead of avoiding the rules for blocking, they seem to instead to the contrary, they actively seek them out somehow, so the filter ends up blocking most of the site… you cannot read it without turning it off.

    I hope that gives people out there a tip ;) .

    In the end, you cannot force people to not block your ads if they can, its their choice. However, as you hinted in your article, its about mutual respect.

  • Pingback: Weekend Links - Jan 1, 2009 « OMNINOGGIN

  • Pingback: How to Discourage Visitors from Using AdBlock « OMNINOGGIN

  • Timverba

    “Add value to your ads and they won’t be blocked”
    Thank you for making AdBlock more and more popular.
    AdBlock is the best application to remove ads.
    AdBlock makes internet faster.
    AdBlock will force companies like Google to reinvent their business.
    (This is NOT advertisement for AdBlock)
    Best use “AdBlock Plus”, the improved AdBlock fork.

  • Thaya Kareeson


    You sound so absolute in your statements. Please see my comments.

    > “Add value to your ads and they won’t be blocked”
    Can you give me an idea of how to add value to my ads other than publishing only advertisements relating to my website content?

    > “AdBlock makes internet faster.”
    That’s not true. It just SEEMS faster to you. All AdBlock software does is set the CSS property of different blocks of code to “hidden”. The content of the ad still gets loaded in the background, but you do not see it. You are still using the same amount of bandwidth to load the same page with AdBlock on or off. So, “No, it does not make the internet faster.”

    > “AdBlock will force companies like Google to reinvent their business.”
    What do you have against Google and their AdSense business model? I think they’re doing a pretty good job at displaying context related advertisement.

  • Matt

    Thank you, Thaya, for helping to keep the comments here from becoming one big AdBlock Plus commercial. :) You certainly have some good points.

    To everyone who objects to this article, note that I am simply demonstrating, not saying “everyone should do this.” In fact, I greatly discourage the use of these methods by sites that run obnoxious ads. I intend it for the sites that do “add value” to their ads. You should read my full opinion on ad blocking here:

  • Artem Russakovskii

    While I support relevant advertising and enjoy this topic, I want to point out a possible inaccuracy in Thaya's explanation of "AdBlock makes internet faster".

    I am fairly sure that Adblock Plus does prevent the actual download of blocked elements. For example, I block off a certain annoying .wav file that nagios uses to signify errors and it never gets downloaded. Since it's a sound and I don't hear it, I don't think it's just manipulated by some CSS property and therefore it's possible to use Adblock to save bandwidth.

    I could be wrong though.

  • thaya

    @Artem Russakovskii
    You are right. There are actually two ways AdBlock blocks advertisements. Once is to hide HTML elements and others to intercept HTTP requests (used on direct media requets, i.e. .jpg, .png, etc.) Boy, I feel stupid now. Sorry for the misinformation!

    • redwall_hp


      Oh well, your other two points were still good. :)

  • jazmine

    so if u have any add is it hard to deal with no!!!!!

  • Claude Gelinas

    Thaya makes excellent points, in his previous comments!

    As a full time, independent web publisher, I hardly have time to create content -and- sell ads. Using Google's AdSense ads makes sense, no pun intended, for me.

    Unfortunately, the rise of ad blocking extensions have slashed my revenues by close to 70%, which is a financial stress that I've had to make up for by charging visitors for premium content, elsewhere, which is sad for the people who now have to pay for stuff that was previously offered for free.

    All of that because of Adblock Plus and similar extensions hurting web publishers.

    The "everything is blocked out of the box" approach of these extensions are killing the free web, by the day. Google will survive because they serve their own ads, in their own networks, without using any JavaScript but the web publishers (affiliates) will get hit much harder and lots of them will have to look for alternatives.

    In my view, people using ad blocking extensions —who know what harm it does to web publishers— are nothing short of freeloaders.

  • Aerik

    Wow. You’re a douchebag. You’re actually making something to force somebody to download something against their will.

    Look, you could just ask users to not adblock your site. You could even provide us with a list of whitelisting filters that apply only to your site. You could even create your own subscription that applies only to your site that updates as you update your site.

    But no. Instead of communicating with your users, you went around them, you got sneaky.


    • redwall_hp

      "You're actually making something to force somebody to download something against their will."

      Nobody's forcing you to load the page. That's your choice entirely. So if you buy a magazine, I suppose the ads in there are being loaded against your will as well? A web page is a finished product, like a magazine. If you load it, you get the whole package. Besides, you would be the one blocking ads against my will. The ads pay for the site; if you can't put up with unobtrusive (yes, unobtrusive, have you looked?) advertisements, then don't read it. That's entirely your choice.

      • beppe9000

        Uhm… are ad displays registered, whn using a ad-blocker?

  • randomnut

    Using the Internet without AdBlock has become funny. It’s just like in the comedy movies. Screen full of ads.
    Once more people become aware of AdBlock, push advertising will come to an end. That is ethical, in my oppinion.
    I believe the only advertising that should be done is the ‘pull’ type, where the user REQUESTS ads – for example when they need a product.

  • dreamsburnred

    Personally I do not use adblock. As well the websites that I view none of them have annoying ads..except for pc world. Sites like,,, and my blog have ads that are related to the content but don't scream click me!!

    As well ads for free content is just fine. :)

  • Mike

    It’s very sad a lot of people don’t seem to understand that creating content for a website costs a lot of time. That developing a cool web application or game, costs a lot of time. That putting and keeping your website online and up-to-date costs a lot of money. While most of today’s website are free, I think in the future a lot of website are going to rethink their business model and charge the user visiting their content. Just like in the old days… the good old days.

  • 7

    Im using Adblock plus :cool: and anti-adblock script doesnt work hahaha

    • Thaya Kareeson

      @7, It works for me on my sites.

    • Matt

      I’m not using anti-adblocking right now. As fun as it is, some of my tricks would interfere with my network’s ad serving. It just wasn’t worth the effort.

  • Cirke

    Everyone who is using Adblock is a moron, and you don’t respect the whole Internet because without ads the Internet cannot be free! I wanna see you when websites will require a monthly fee to use the site… because nobody will click on their ads, but this will never happen because nobody want’s that :)

  • Christina Marie

    If you don’t like the ads, don’t visit the site and utilize its resources. Kind of hypocritical and one sided isn’t it to go to a site you like but complain about how they make money. I put a lot of time and resources into building informational FREE sites for people. Costs are offset by putting up ads. So like I said, if my visitors don’t like it, they can go somewhere else.

  • Bob

    I can’t believe there really are people out there who want absolutely everything for free. Viewing ads is a small price to pay for getting something.

    I’m working on re-showing ads blocked on my site or blocking the users from seeing, free loading (leeching) users are worthless to me so they can jog on for all I care.

    • Joe

      Sure, when the ad-provider and site-owner practice considerate usage for their ads. Just enough, and proper content. But this is rarely the case. Some sites (talking to you, porn world) are more ads than content, some force you to even interact with their ads before they’ll let you pass on to their, often meager content, and even Google seems to feel ad-heavy sites are a bad thing, and ranks them accordingly low, now.

      So a few peas spoil the pod, and all ads get blocked. Personally, as a PPC advertiser and a consumer myself, I look forward to an evolution away from ads. It’s a really unengaging model that nobody enjoys. The web host has to allow ugly, often deceiving ads onto their site, risking an SEO hit, and consumers need to wait for and maneuver around flashing, often audible ads just to read a blog post about nothing or watch a video of a cat.

      But that response was 4 years ago, and ad blocking has doubled over since then. I’m curious what Bob thinks today, and how well his ad farm’s doing.

  • Jupitarr

    This is scary. You sound like a bunch of senior citizens complaining about kids with baggy pants. Of course we want everything for free. Are you so dilusional? There are plenty of free internet sites that do and do not provide services that generate revenue(without ads). I have one. Who in their right mind even clicks on ads anymore? I presume that clicks are the most common way of generating revenue? You can start charging for your site if the information is worth paying for. Who said you had to provide it for free? On a side note, I hear artists can’t make music for a living anymore because of the internets. The attitude I’m seeing here is what leads to horrible legislation like sopa and pipa. You tweak your programing, I’ll tweak mine.

  • Adam

    Matt, thank you so much for this post! It helped me solve a frustrating issue.

    I was designing a website, and certain images (such as icons for my buttons) weren’t showing up when live. All the standard inspection tools said everything was fine.

    It turns out ad blockers can be pretty nasty for even non-ad sites, by SILENTLY blocking LOCAL, INNOCUOUS, TINY files if they simply contain a keyword like “ad” in their path. In my case I was using something like “../images/ad-types/blah.png”.

    I wonder how much legitimate content is being unknowingly blocked from websites that happen to use the wrong filename? It seems that ad blocker testing should now become a standard part of the design process, since the over-zealous extensions are very popular. My next recommendation would be to ditch them or have the default be click-to-hide, but it’s doubtful that ad blocker devs and users will ever head in that direction.

    I have mixed feelings about the ethics of ad blocking. But I’m wary that the more that ads cheat the blocking, the more loose the detection conditions will become, making the above situation more common. I would suggest that ad-supported sites offer a fallback image that politely notifies the user the reason their site is free, and/or offers the option of a one-time donation to eliminate ads (OkCupid does both of these things, in addition to optional “premium” pay accounts).

    Anyway, I hope your post helps many others with the issue I encountered, and continues to stir the whole ethics debate.

  • mikeloeven

    I wouldn’t use adblock if i could trust the types of sites i visit to use normal passive banner and image ads. but currently i cant go 5 minutes without some script greying out my screen and showing a unskipable video of some random dude screaming about something.

    i get that adblocking is bad for a websites bottom line but damn it when will they learn that people pay more attention to “SERIOUS” ads rather than flashy gimmicks that disrupt the users ability to navigate a site.

    the issue with ad blocking is it is just easier than trusting a developer to not annoy their users.

    i mean i belong to a few websites dedicated to video game reviews and mods. and where one would think that this type of site would use the flashy video and audio monstrosity most of these sites use text or banner ads on the top and borders. lord knows i have actually purchased some of the advertised games that i otherwise would have completely missed.

    so take advice from the gamer nerds they know how to build websites that don’t piss people off

  • Ivan

    The floats, popups and other seriously annoying stuff is what drives users to install ad-blocking software. Unless you’re on dial up with 99 hardware, no one minds ad banners. Even flash banners. Politely asking users to disable ad-blockers for your site is the way to go. People do listen and oblige. Don’t fight your users.

  • Vuthy Ry

    Could I know whole code of add hiding behind background image or feature image?

    Possible could you send me by email