Blocking JavaScript on a per-site basis with Safari

Two or three years ago, I started using a content blocker on Safari, both on the Mac and on the iPhone. I started with the good K-Block and soon switched to the excellent Wipr, which is still the one I recommend. Somehow, I always feel a little bit of shame and guilt when talking about content blockers, especially ad blockers. Obviously ads are too often the only way many publishers manage to make decent money on the internet: every newspaper can’t be financially successful with subscriptions, and every media company can’t survive only on contributions and grants.

But not all ads are created equal. For instance, what is astutely called “Surveillance advertising” is bad, and I think it should be more regulated to protect privacy. Other ads just make the web impossible to use and are therefore serving a purpose going against what they are supposed to do in the first place: generate money for publishers, not push away visitors from their website. But I digress, this is a very complex topic, and there is so much to say on the matter. Back to content blockers.

Prior to my use of proper content blockers, I used what I would call “privacy-protection” extensions, like DuckDuckGo’s Privacy Essentials, back when it was only an extension, and not a browser.1 With it, ads were not blocked or hidden, but at least I felt more protected from the dozens of aggressive and invasive trackers found on the web today. It was great, until it wasn’t: The web is such in a poor shape today, that this kind of blocker was not enough for me to simply enjoy the web.

This is what I wrote last year on a post titled Browsing the web in 2021 is a terrible experience:

Last week, I tried to use my devices without a content blocker for a few days. I quickly learned that a content blocker, just like WhatsApp, […] is an essential app that I need to keep around.

Well, things aren’t really better in 2022, are they?

An alternative to proper content blockers

Wondering if a content blocker was the only solution to this problem and searching for alternatives, I remembered this 2017 post by Charlie Owen regarding JavaScript, shared by John Gruber on Daring Fireball, where Owen says:

Well, with just a few minutes of sans-JavaScript life under my belt, my first impression was “Holy shit, things are fast without JavaScript”. There’s no ads. There’s no video loading at random times. There’s no sudden interrupts by “DO YOU WANT TO FUCKING SUBSCRIBE?” modals.

If this were the only manifestation of turning off JavaScript, I’d do this for the rest of time. However, a lot of things don’t work. Navigation is the most common failure mode. Hamburger menus fail to internally link to a nav section (come on, that’s an easy one kids).

I was also seduced by this idea of disabling JavaScript. In a way, I would not filter out ads specifically, I am just disabling the technology most of them need to appear, track, and exist. If you feel like it is a little like cutting power from your house to turn off the lights, you’re right: it is a bit radical.

On the Mac, at first, I added a keyboard shortcut to the Develop menu of Safari, to enable/disable JavaScript, but it is not practical since it can’t be done on a per-site basis, and not even on a per-window basis. It is either on or off, and on iOS the switch is buried deep in settings so this was definitely not a good solution.2

I tried Jeff Johnson’s good little extension called StopTheScript, which does what it says: stop JavaScript on a per-site basis. But it didn’t work for me either. There is no Mac version, and the extension leaves JavaScript on by default, and you have to turn it off on individual sites, which is not what I want, but this may work for you.

It is possible and it works… for now

This week, I downloaded JavaSnipt, and it does exactly what I was looking for: per-site enabling of JavaScript, and off for all websites by default. The extension is available on the Mac and iOS, and so far, it seem to work OK, despite a few glitches here and there, especially the Safari toolbar shortcut that doesn’t seem to work at all.

Many websites use JavaScript, and not always for obvious reasons. When the extension is on, some of them don’t even load at all. Sometimes the page loads without images. But for reading articles, it mostly works, most of the time. For instance, this article by Chris Ashton, where he explains the reasons why most sites use JavaScript these days, renders pretty well without JavaScript:

It’s interesting to see that relatively simple sites — Instagram and LinkedIn particularly — have such poor noscript support. I believe this is partly down to the ever-growing popularity of JavaScript frameworks such as React, Angular, and Vue. Developers are now building “web applications” rather than “websites,” with the aim of recreating the look and feel of native apps, and using JavaScript to manage the DOM is the most manageable way of creating such experiences.

There is a danger that more and more sites will require JavaScript to render any content at all.

We will see how this JavaScript-blocking-by-default experiment goes. There is a bumpy road ahead of me. It will require some efforts and time to build a functional “allow-list” on JavaSnipt so that I can browse the web without thinking too much about it. Or maybe I’ll switch back to Wipr in a few days. Or maybe I’ll just give up on content blockers altogether and punish myself with all the ads.

By blocking JavaScript — and this is the reason why I want to try to do this — I don’t feel like I’m blocking ads, and I somehow feel less guilty than when I use a proper ad blocker. It’s hard to come up with an analogy, but it’s a little like: I don’t skip commercials when I watch TV, I just don’t own a TV. Does it make sense? What kind of content blocker are you using? Let me know by email: I’d love to hear your take on this.


  1. I like what Firefox Focus does in that regard: it is a browser, but you can just use it as a privacy-protecting Safari extension if you prefer. Very smart.↩︎

  2. One thing that would be neat: if Safari added a native JavaScript option alongside the “Use Reader when available” and Enable content blocker” options of the “Settings for [website]” menu.↩︎