Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experiment with replacing if-domain/unless-domain with if-top-url/unless-top-url #20

Open
ameshkov opened this issue May 21, 2021 · 2 comments
Assignees
Labels

Comments

@ameshkov
Copy link
Member

ameshkov commented May 21, 2021

Example:
if-domain: [ "example.org", "*example.org" ] --> if-top-url: [ "^[htpsw]+:\\/\\/://([a-z0-9-]+\\.)?example.org/" ]

Ideally, we'll simply need a JSON built with this new approach. Once we have it, we'll be able to see how long it takes Safari to compile such a content blocker and whether it's faster or not.

@ameshkov ameshkov added the enhancement New feature or request label May 21, 2021
@ameshkov ameshkov changed the title Experiment with replacing if-domain and unless-domain to if-top-url and unless-top-url Experiment with replacing if-domain/unless-domain with if-top-url/unless-top-url May 21, 2021
@maximtop
Copy link
Contributor

maximtop commented Jun 21, 2021

Regex from the subject is not correct, I've used the next one.

{
    "trigger": {
        "url-filter": ".*",
        "if-top-url": ["^[htpsw]+:\\/\\/([a-z0-9-]+\\.)?example.org"]
    },
    "action": {
        "type": "css-display-none",
        "selector": ".banner"
    }
}

I've generated random 50000 rules like example.org##.banner and reloaded content blocker.
Rules with if-domain trigger were loaded faster

  • if-domain - 2.2 seconds
  • if-top-url - 4.2 seconds

After that, I've tried the filter with real rules https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_2_English/filter.txt
And again rules with if-domain trigger were loaded faster

  • if-domain - 6-8 seconds
  • if-top-url - 9-12 seconds

With both kinds of triggers I didn't notice that the browser become slowly

@ameshkov
Copy link
Member Author

We should do that experiment one more time after iOS 15 is out and we can create content blockers with 150k rules. I am not yet sure how important this slowdown will be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants