July 8, 2015

Thoughts on Safari Content Blocking and the hosts File

iOS 9 and OS X El Capitan adds the ability to block content natively, which means that there will be a proliferation of iOS and Mac ad blockers when these updates drop.

Ad blocking has been around for a long time, generally through browser extensions. I think this kind of browser extension is a terrible idea, because these extensions have the same access to your browsing as someone standing next to you: they can read everything you read online, and could in theory send this to a third party server.

Setting ethics aside,1 Safari content blocking is a big win for users. It is much more secure than ad blocking with a browser extension, and likely will run faster too.


There is already a way to securely block ads system-wide. It involves adding 11,695 lines to your hosts file, which blocks your computer from accessing the domain names of known ad and tracking networks. This is secure because the integrity of the hosts file is easily verifiable (just make sure all non-comment lines start with 0.0.0.0).

I have been using this for about 5 months and haven’t noticed any problems with legitimate content being blocked, apart from Gaug.es being on the blacklist erroneously (it was since removed). You’re mileage may vary.

The big downside to blocking ads with the hosts file is that it involves editing the hosts file, a system-level file that if modified incorrectly could break networking on your computer. Clearly, this is not a solution for the masses.

Apple’s implementation of content blocking actually is similar to using the hosts file in that it can block content from a list of specific domain names, but Apple’s system provides much finer-grained control. It also works on iOS; hosts file editing is Mac-only, unless you jailbreak.


One example of why there is demand for ad blocking is iMore, a much-beloved Apple-centered news site. Without content blocking, this iMore page is 14 MB according to John Gruber. With my hosts file content blocking, it’s only 2.29 MB (with 21 “file not found” (404) errors from the hosts file blocking ad network HTML, JavaScript, and images).


  1. I believe in ad-supported content, but not when the ads are annoying auto-playing animations – or worse, auto-playing video with sound. These kind of ads make webpages unreadable, and use a lot of CPU, bandwidth, and battery power. I consider blocking these sorts of ads the same as recycling the advertising insert in the newspaper without looking at it. “Native” advertising is much better, assuming it is labeled clearly as such, and is the future of advertising on the web. I would not try to block native ads. [return]

Comments? Please send me a message.

Subscribe via RSS or email.