[webkit-help] Content Blocking

Benjamin Poulain benjamin at webkit.org
Tue Jun 23 15:28:22 PDT 2015


Hi Brent,

On 6/22/15 10:11 AM, Brent Montrose wrote:
> I have another question regarding Content Blocking, and performance.
>
> For the "Action" types of "css-display-none" are the following two
> examples effectively the same (hiding content on example.com)?
>
> Example 1:
>
> "trigger": {
> "url-filter": "^https?://([^/]*\.)?example\.com"
> },
> "action": {
> "type": "css-display-none",
> "selector": ".ad"
> }
>
> Example 2:
> "trigger": {
> "url-filter": "^https?://",
> "if-domain": "example.com"
> },
> "action": {
> "type": "css-display-none",
> "selector": ".ad"
> }
>
> Example 1 explicitly specifies the domain in the "url-filter".
> Example 2 uses a very generic "url-filter", but utilizes the
> "if-domain" restrict which domains the selector would be applied to.
>
> Are these two rules effectively the same?  (I think they are based on
> my understanding).  Also, is there a performance difference between
> the two?  If so, which one would perform better, and why?

The rules will not have the same output.

The filters "if-domain" and "unless-domain" are applied to the main 
document's URL. The "url-filter" regular expression is always applied to 
the current resource being tested.

The first rule will inject the selector ".ad" on any document loaded 
from example.com and any of its subdomains.

If you are on trusted-source.com and it has a script loading from 
example.com, it will be blocked.

The second rule will inject the selector ".ad" on any resource loaded 
when you are on example.com, regardless of their origin.

If you are on trusted-source.com and it has a script loading from 
example.com, it will go through.

Performance wise, both are extremely fast. You can have several 
thousands rules of either type without suffering any performance impact.

Benjamin


More information about the webkit-help mailing list