[webkit-help] A few questions about Content Blocking Extensions in Safari 9
Benjamin Poulain
benjamin at webkit.org
Tue Jun 16 15:08:52 PDT 2015
On 6/16/15 10:03 AM, Brent Montrose wrote:
> I've been reading the article on newcontent blocking mechanism,
> introduced with Safari9
> (https://www.webkit.org/blog/3476/content-blockers-first-look/), and
> the emails regarding the subject. The article and email response was
> helpful, but I have a few additional questions.
Brian, who works on the Safari part of Content Blockers, is on vacation
this week.
I'll try to answer but he will have better information next week.
> 1. Does an extension need to set the rules each time the browser /
> extension starts up? Or, will Safari 9 cache the rules between
> restarts?
As far as I know, you need to set the rules every time the extension
starts up.
Setting the content blocker is a somewhat expensive operation. The
compiler needs to run over the extension and optimize it, which can take
some time.
You only pay that cost the first time the extension is set. The compiled
version is cached and is reused if you set the same extension a second time.
> 2. Is there a easy way to pause content blocking & hiding for a
> short period time? Or rather, what is the recommended approach to
> pause content blocking? For example, a user navigates to a web site
> and wishes to view all of the content on that page without
> white-listing the specific site. If I understand correctly, to pause
> content blocking, the extension would currently need to set / submit
> an empty JavaScript object to effectively clear the current rules.
> Then, later, when the user wishes to enable content blocking again
> (un-pause), the extension would need to set all of previous rules
> (which could be expensive).
You can disable your own content blocker by passing null to
setContentBlocker().
I have to say it is not the ideal scenario for power usage. When you
will re-enable your extension, it will go through the compiler again.
Can you please file a bug report on http://bugreport.apple.com
explaining the use cases you have in mind? You can send me the bug
number and I'll CC the team.
We should see what is the best way to handle that, it could be as simple
as keeping the last compiled version when removing a content blocker.
Benjamin
More information about the webkit-help
mailing list