How Ad Blocking Works

, Posted in Blog,
Block Like a PRO!
Windows laptop with adlock
Try AdLock for free on your Windows device
Adverts and data collectors - two birds. AdLock - a stone that never misses.

The simplest solution to stop online ads is to round all advertisers up and exile them somewhere on an uninhabited island. Let’s see how they will sell online casino to each other under such circumstances, right? Although this idea sounds quite entertaining and can be the basis of some reality show no one has the time for it. In this article, we will tell you how ad blocking works to get you closer to the bottom of this mystery.


In few words, ad blocker like AdLock doesn’t allow your browser or other apps that display web content to download ads. This can be done in several ways: AdLock can block communication between a browser and advertising server or block connection with a website from its blacklist. The most important thing is to settle explicit ad-blocking filters so that an application can’t block the whole innocent web source by mistake.

Where do ad-blocking filters come from

In general, it’s easy to recognize ads as most of them are downloaded from similar web servers. The complicated part is to identify which content is commercial and which is not and to settle accurate rules of displaying. Maybe in foreseeable future, we will be able to delegate this menial work to artificial intelligence but so far thousands of developers and just non-indifferent people all over the world work daily on creating the fullest list of ad-blocking filters. Ad-blocking filters give instructions to an application on which content shouldn’t be downloaded.

When you install ad blocker for Android, you’ll get an opportunity to customize advertising filters. For example, if you have few favorite websites which you know live on ads, you may add their URLs to the list of exceptions. Websites will continue making a profit, and you will feel better about yourself.

It’s a global practice for all modern ad blockers, including AdLock to use established and permanently improving filter-list from the web but apart from that, AdLock develops its own filters likewise. It helps to enhance our application and stay one step ahead of the competition. AdLock’s ad blocking process is based on those filters and conducted in 5 steps: 1) DNS filtration, 2) URL filtration, 3) Content filtration, 4) CSS injection, 5) JS injection. Below we will take a close look at each of five steps separately.

  • DNS filtration

Before downloading a website your browser or an app sends request to your operating system, and it returns a valid IP address. AdLock mediates between these processes. For example, let’s say AdLock is a telephone operator and an advertising domain server is a dial number. When your browser tries reaching ads server through the operator which is AdLock it tells that this number doesn’t exist. Browser doesn’t reach advertising server, thus it can’t download ads from it.

Try for free today!
Windows laptop with adlock
Try AdLock for free on your Windows device For Windows
Android phones with AdLock
Try AdLock for free on your Android device For Android
Adlock Extantion Try AdLock for free in your Chrome browser For Browsers

Despite the simplicity of DNS filtration, it stays imperfect as it ruins the way website is displayed. The thing is websites want to make a profit, and they write adverts into the source code. When we forbid our browser to download commercial content it lefts empty spaces where ads and banners supposed to be. The end result would be similar to artworks of Jorge Pérez Higuera, a Spanish photographer who presented how the world would look without ads. We can’t let you use a website with such a catastrophic design. That’s why we apply number of other filters to return a web page harmonious look.

how to block ads - dns filtration - adlock

  • URL filtration

DNS filtration can be successfully applied only if ads are downloaded from the third-party domain. If ads are located on website’s domain, we need to analyze the website’s URL. Let’s imagine a website with the URL, the advertisement on this website will be downloaded from the URL URL filter reads a website’s URL and checks whether it requests for the advertisement content and if so, URL filter blocks such request.

Take into account this filtering method (and all of described further) needs certificate installation for filtering HTTPS connections.
  • Content filter

Before letting your browser to download a website AdLock’s content filter scans the contents of the website’s HTML source code and cuts of elements that don’t pass ad-blocking filters. This filtering algorithm scans each HTML element (going down from the head of HTML tree to each subelement) according to filtering rules, taking a lot of CPU time and process memory.That why this method of ad filtration is considered to be outdated, as more effective and modern methods exist (see below).

how to block ads on google chrome - adlock

  • CSS injection

CSS injection applies after DNS, URL and Content filtration. First, let’s figure out what is CSS. CSS stands for cascading style sheet through which website developers tell our browser how to display each web-page (which colors to use, what font, images, etc.) CSS also specifies the size of spaces reserved for adverts, that’s why when DNS filter blocks ads there are holes left instead of them in the website design. In order to put those holes away, we apply our CSS injection the moment browser downloads a website. CSS injection tells that adverts spread over zero pixels in length and zero pixels in width or as such don’t exist. Next, content elements pull up to take advert places returning web-page clear and laconic exterior.

  • JS injection

In many cases, developers don’t use direct link or frame to download advertising on a web-page. Frequently they use a custom javascript to tell your browser where, from where, and what ads elements it has to download. After browser completes to download all HTML content elements of the page JS script runs to settle banners, pop-ups, etc. You undoubtedly noticed that on some websites ads appeared only when a current web-page completed rendering. It was especially evident if you had a bad connection or slow internet. Thereby Javascript provides data for adverts to appear on a website whether they are downloaded from third-party domain or written into the source code. In order to suppress advertising scripts, we inject own JS code which contains all ad blocking mechanisms to counteract ads.

Block Like a PRO!
Windows laptop with adlock
Try AdLock for free on your Windows device
Adverts and data collectors - two birds. AdLock - a stone that never misses.