Browsers, News & Events

iOS 9 Allows Ad Blocking In Safari

Though ad blocking in Safari did not get a mention in Apple’s keynote announcements at WWDC 2015 but deep within the developer’s documentation lies the important feature. The developer documents suggest that Apple is building support for ad blocking apps, with a new API. The company has quietly let slip that Safari will include support for content blocking extensions or in other words, it can block ads. The new Content Blocking feature will allow developers to pass a JSON file.

Here’s what the developer documentation says about ad blocking in Safari:

The new Safari release brings Content Blocking Safari Extensions to iOS. Content Blocking gives your extensions a fast and efficient way to block cookies, images, resources, pop-ups, and other content.

Your app extension is responsible for supplying a JSON file to Safari. The JSON consists of an array of rules (triggers and actions) for blocking specified content. Safari converts the JSON to bytecode, which it applies efficiently to all resource loads without leaking information about the user’s browsing back to the app extension.

Xcode includes a Content Blocker App Extension template that contains code to send your JSON file to Safari. Just edit the JSON file in the template to provide your own triggers and actions. The sample JSON file below contains triggers and actions that block images on

ad blocking in safari

The desktop version of Safari allows a variety of custom extensions and the most popular among them is AdBlock.
Apple has not provided in-depth details about the new Content Blocking feature as of now. But, it is supported by Safari on OS X in the upcoming EI Capitan release.

iOS 9 will launch in fall and then you will be able to download the extension that will block ads. It is yet to be seen how Apple will let content blockers get into the app store. Hopefully, more details about ad blocking in Safari are soon to be included and we will update you accordingly.

Whether you are a developer or a user, what are your thoughts on this new change by Apple? Let us know in the comments!

If you like our content, please consider sharing, leaving a comment or subscribing to our RSS feed to have future posts delivered to your feed reader.

Please follow us on twitter @CodeRewind and like us on facebook

You Might Also Like