X Browser’s ad blocking module has undergone extensive optimization to address the performance limitations of mobile devices compared to PC browsers. While ensuring performance, it maintains compatibility with as many blocking rules as possible. The ABP syntax rules have been simplified, and X Browser has extended some of its own blocking rule syntax. Currently, it is compatible with over 90% of ABP blocking rule syntax. Tests show that importing 200,000 ABP blocking rules still maintains good performance.
X Browser’s ad blocking achieved a perfect score of 100 points in the ADBlock Tester test. For details, please refer to this article - Test the Effectiveness and Compatibility of Ad Blocking.
From the perspective of how ad blocking works, we divide blocking rules into two major categories: URL Blocking Rules and Hidden Element Rules. Below we briefly introduce the working principles of these two types of blocking rules.
Series Navigation
- Current: Ad Blocking Introduction
- Next: URL Blocking Rules
- Hidden Element Rules: Writing Hidden Element Rules
- Exception Rules: How to Write Exception Rules
- Strong Blocking: Strong Blocking Mode and Rules
What You Will Learn
- Difference Between Two Rule Types: URL Blocking Rules vs Hidden Element Rules
- When to Use Which: Typical scenarios and pros/cons
- Next Steps: Detailed syntax for various rules (related reading provided at the end)
Quick Navigation
URL Blocking Rules vs Hidden Element Rules
| Dimension | URL Blocking Rules | Hidden Element Rules |
|---|---|---|
| Timing | Before resource request | After page rendering |
| Saves Bandwidth | Usually saves more bandwidth | Generally doesn’t save bandwidth (resources already loaded) |
| Typical Target | Ad JS/CSS/image resource URLs | Ad modules directly embedded in page |
| Possible Issues | False positives causing functionality issues | Ads may flash briefly before disappearing |
| Use Case | More effective for “ads loaded as resources” | More effective for “ads mixed in DOM” |
URL Blocking Rules
When browsers render pages, they need to load many resource files, including JS scripts, CSS stylesheets, images, etc. Many ad resources are hidden in these resource URLs, such as JS scripts used to display ads. Some advanced users simply disable JS script execution to block malicious ads. However, disabling JS scripts may also prevent web pages from working properly, so the best approach is to identify which resource URLs are likely used to load ads, allow normal resource URLs, and block malicious ad resource URLs.
URL Blocking Rules primarily function to match URLs that load ad resources to block malicious ads. These rules are typically combinations of domains, paths, and query strings, like the following:
||apologyjaguar.com^ |
The advantage of URL blocking rules is that they can intercept resources before they are loaded, thus avoiding excessive resource bandwidth consumption. Generally speaking, their blocking performance is also good.
Hidden Element Rules
Although URL blocking rules are good, they are not omnipotent. In some scenarios, we cannot remove ads by blocking URL resources, such as when ads are not loaded as resources but are directly embedded in the page itself, or when normal business and ads are mixed together in dependent resources. In these cases, we cannot block malicious ads by matching resource URLs.
Against this background, we have another type of blocking rule: Hidden Element Rules. Although called blocking rules, their working method is not blocking but hiding. As the name suggests, this method waits for page elements to finish rendering before identifying and hiding ad elements.
This type of rule actually uses browser selector syntax to find matching elements, then removes them from the browser’s DOM tree to block ads. Below are some examples of hidden element rules:
allmonitors24.com,streamable.com##.topbanner |
Based on this working principle, sometimes we find that ads on certain pages suddenly flash and then disappear, because the ad elements were rendered before they could be removed.
In subsequent articles, we will introduce the basic syntax rules and examples of URL Blocking Rules and Hidden Element Rules separately.
Common Questions
Why can’t some ads be blocked?
Common reasons include: ads are not loaded through independent resource URLs (better suited for hidden element rules), or the website’s ad logic is mixed with normal business resources (rules need to be more refined).
Why do page ads flash briefly before disappearing?
Hidden element rules typically wait for the page to render before removing DOM elements, so there may be a brief flash of “rendered first, then hidden.”
Will importing many rules cause lag?
X Browser is optimized for mobile performance. The test results mentioned at the beginning of the document show that importing about 200,000 ABP rules still maintains good performance.
Related Reading
- URL Blocking Rules
- Writing Hidden Element Rules
- How to Write Exception Rules
- Strong Blocking Mode and Rules