iOS 9 comes with a new feature called “content blocking”, which allow us to install apps that block trackers, advertisements and other content – cookies, images, resources, pop-ups while browsing websites on iPhone safari browser. It means that things like autoplay video, invisible tracking scripts (which hinders the privacy unknowingly) etc. can be blocked.
Why do we need them?
- Most of the websites today are filled with so much of “extra” content beyond the information we are looking for like ‘third-party trackers’ to enable advertising, analytics and other marketing tools to show advertisements.
- Desktop browsers can load such websites fast because of powerful resources and are generally connected to hi-speed internet like broadband or lease lines.
- Mobile browsers on the other hand have limited resources and are generally connected to data plans like 2G, 3G services. Loading these websites on mobile browser can be troublesome, slow, bulky, unstable and annoying. It also consumes a large amount of data thus increasing data usage, battery usage and more mobile bills.
All these limitations can be overcome d with content blockers that can:
- Stop all this extra content from been loaded so that websites can load fast and we are presented with only those information that we are actually interested in reading.
- Stop the scripts and cookies that let sites and their advertisers identify us and follow us around the web.
- Stop the trackers that track our information and utilize it thus solving our privacy concern to some extent.
Content blockers themselves aren’t logging what sites we visit or what’s been blocked. They just use a set of defined rules that tell the browser what should not be loaded.
How do they work?
- Content blockers in iOS 9 are new types of app (called extensions), that are able to block incoming content before it’s loaded by the system — it provides a list of sites and scripts to the operating system for blocking. Instead of requiring the browser to process what to block as the page loads, it’s performed on a system level before the page loads which increases speed significantly.
- We will first have to install a content-blocking extension by way of a mobile app download from the iTunes App Store.
- But unlike normal iOS apps, these new apps cannot run just by installing them, we need to change few device settings to turn them on – “Settings” -> “Safari” -> “Content Blockers”.
- We also have an option reload the website without content blockers, by long press on the reload button in case if we want to see the blocked contents.
Content blockers for developers
- To create a content blocker, developers add a Content Blocker Extension template in Xcode and create a list of rules in a JSON file. The rules define what gets blocked. The rules contain triggers and actions. Triggers determine when the rules get run and actions determine what happens when they do.
- For page elements like divisions (div), the trigger can be as simple as coming across a CSS class and the action, setting its display property to “none”. For example, if “#about-the-author” is encountered it can be made to go away. Developers can choose to target all domains, or to include or exclude specific domains. They can also choose to target all resources or to include or exclude specific resources.
- For scripts, it can be as simple as blocking them from loading. Again, developers can choose all scripts or to include or exclude specific scripts, and to exclude first party (same scheme, domain, and port as the page itself) or third party scripts.
- Filtering is handled by regular expression (regex). Developers can even create rules that, if the proper conditions are met, negate other rules.
- Since developers can provide ways to change rules in the app that contains the extension, in action extensions, and in Settings, developers can notify Safari about updates and have the rules recompiled. That includes when white lists or black lists are imported or re-imported, sites are added or removed, different elements or resources are enabled or disabled, etc.
Few concerns
While mobile web users will appreciate the ability to block ads, speed up load times, save money on expensive data plans, and protect their privacy, the addition of content blockers in iOS 9 could have huge complexity for web publishers and their advertisers.
Tools that publishers routinely use to measure their visitors and communicate with them, including Google Analytics, Parsely, Chartbeat, Intercom, Optimizely and others could also be affected. Workaround for publishers could be:
- Use ‘News’ app (available in iOS 9, where it’s not possible to block ads).
- Use iAd network for advertising.
- Build native apps.
While content blocking in iOS 9 is fairly new feature, our expert mobile development team has already started to implement it, please feel free to contact us for any related queries.