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 casinos to each other under such circumstances, right? Although this idea sounds quite entertaining and can be the basis of a 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.


Simply put, an 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 adblocking process is based on those filters and conducted in 5 steps:

  • DNS filtering
  • URL filtering
  • Content filtering
  • CSS injection
  • JS injection

Below we will take a close look at each of the five steps separately.

DNS Filtering

Before downloading a website your browser or an app sends a 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 the ads server through the operator which is AdLock it tells you that this number doesn’t exist. The browser doesn’t reach the advertising server, thus it can’t download ads from it.

Despite the simplicity of DNS filtration, it stays imperfect as it ruins the way the 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 are supposed to be. The end result would be similar to the 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 a number of other filters to return a web page harmonious look.

how to block ads - dns filtration - adlock

URL Filtering

DNS filtering can be successfully applied only if ads are downloaded from a third-party domain. If ads are located on the 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 the advertisement content and if so, the 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 download a website AdLock’s content filter scans the contents of the website’s HTML source code and cuts off elements that don’t pass ad-blocking filters. This filtering algorithm scans each HTML element (going down from the head of the HTML tree to each subelement) according to filtering rules, taking a lot of CPU time and process memory. That is why this method of ad filtering 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 is applied after DNS, URL, and Content filtering are done. 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 the 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 the web page its clear and laconic exterior.

JS Injection

In many cases, developers don’t use direct links or frames 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 the browser completes downloading 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 a third-party domain or written into the source code. In order to suppress advertising scripts, we inject our own JS code which contains all adblocking mechanisms to counteract ads.

What Are Ad Blockers?

Essentially, an adblocker is a software unit. Depending on the developer and the product, adblockers vary from simple browser extensions working on browsers while others are standalone programs covering all browsers and programs on users’ devices. Despite the name, adblockers don’t actually block ads in the literal sense. Definitely, they remove ad-containing blocks and frames from displaying but it doesn’t mean advertisement goes away from the Internet.

How do Ad Blockers Detect Ads?

The algorithm for tracing and blocking ads is different from adblocker to adblocker but the fundamental goal for each of them is to read/listen to the content loading while the webpage is getting ready to be displayed to the user. Before any content is rendered, adblockers compare it to a filter list, block matches, and then tell the browser what to render. So, basically, adblockers have the final word determining the content to be displayed. Carefully curated and maintained filter lists help adblockers to clean up users’ online activity in an elegant way.


Is ad blocking safe?

Talking of safety, you should only trust legitimate apps and services. There are dozens of diverse scam “adblockers” from noname developers making people fall victim to tricky scammers and lose faith. Oftentimes such scam services operate using similar names to legitimate apps. But if we talk of legit products, then it’s worth admitting they will never collect any data concerning your online activity and will never read/process any sort of financial operations on your device.

The cherry on top, some serious and solid adblockers provide additional security tools protecting users from being scammed, phished, or infected with malicious software embedded in ad scripts.

How do ad blockers make money?

It’s an interesting topic. You may say “There are free adblockers, why should I buy one?”, but here’s the thing.
Free adblockers either earn through the acceptable ads program participation, or they collect your data and sell it to advertisers. Paid services in their turn provide full protection of data and additional online security for a fair price of a monthly subscription. Some startups earn through donations but it’s clear that a couple of hundred dollars would not support further enhancements and development, so they search for additional income.

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.