Should Users be Permitted to Disable JavaScript?

Craig Buckler
Share

Get off my lawn! Should Users be Permitted to Disable JavaScript in 2017?

I last raised this question back in 2013 when Mozilla decided to remove the “disable JavaScript” setting from the options dialog in Firefox 23. The primary reasoning:

  • Much of the modern web can break spectacularly without JavaScript.
  • It saves users from themselves. Few people know what JavaScript is and even fewer need to disable it.
  • Those that do can find hidden options elsewhere should they really need it.

Disabling JavaScript remains an option for those in the know.

This popular article has been updated to address the seismic shift in the JavaScript landscape since it was originally published in 2013.

Do Users Benefit From Disabling JavaScript?

Possibly: refer to I Turned Off JavaScript for a Whole Week and It Was Glorious. Without JavaScript, a magical web appears without bloat, advertising, pop-ups, cookie warnings, scroll-jacking and many of the other dark patterns we experience today.

There are also people with perceptual problems who disable JavaScript out of necessity. Few sites consider accessibility guidelines so it remains the easiest way to reduce movement and animated effects which can induce disorientation and nausea.

Article content is normally visible, but the downside is that many web applications fail without JavaScript. Some provide a downgraded experience but it can break shops, maps, games and social networking sites. Content sites powered by modern client-side-only application frameworks may show nothing more than a blank page.

Can You Prevent Users Disabling JavaScript?

No!

It is impossible for site owners or developers to force users to download and run JavaScript. Browsers ‘pull’ files from your server; the user can stop that occurring via browser settings, proxy methods, plug-ins or a range of other interception options.

Your script can also be modified or have specific facilities disabled. Always remember that users are in control: it’s their device and connection. They choose to visit your site and can omit anything they don’t want.

Can You Support Those Without JavaScript?

Few people actively disable scripting. It’s tempting to think those users deserve everything they (don’t) get, but the reality is more problematic. JavaScript is fragile; your scripts can break for reasons including:

  • the HTTP request fails
  • the request did not complete
  • a firewall blocked the response
  • the service provider blocked or modified the script
  • a browser plugin intercepted or modified the script
  • the browser didn’t support the code or facilities you require
  • another script raises an error which stops all scripts executing

These issues are especially prevalent in the mobile world where a user could be travelling, using a less powerful device, connecting via a slow network, using flaky airport wifi, etc.

The solution continues to be Progressive Enhancement. You create the simplest HTML-only experience then enhance it with images, fonts, CSS and JavaScript when those files successfully download and execute. Your JavaScript can detect when APIs/facilities are available to:

  • avoid running code which would result in an error, or
  • load polyfills which implement identical functionality.

Users can receive a different experience. Those using the latest Chrome on a desktop may get the highest level of functionality. Those running Opera Mini on a two year-old mobile may receive a basic styled page. Importantly, everyone receives something and the site/app remains usable for everyone.

Is Progressive Enhancement Worth the Effort?

That’s a decision for you and the application you’re building.

Progressive Enhancement makes sense for content sites and online stores which need to reach the widest possible audience. When implemented well, it incurs little development overhead and can save time. You know all browsers will continue to render your site regardless of updates they receive in the past, present or future.

Simpler applications may also benefit. An app which posts messages to a social network requires little more than an HTML5 form and some back-end processing. Progressive Enhancement then improves the experience by removing the page refresh, adding styles, implementing input validation, providing a character count, handling errors, making it work offline and more.

Progressive Enhancement becomes less viable for applications with rich user interfaces such as office software, mapping, image editing and games. An HTML and CSS-only solution may be too cumbersome to be practical. That said, you should show something even if it’s just “sorry, you require JavaScript”.

JavaScript Blocking in 2017 and Beyond

The question “should users be able to disable JavaScript” has little relevance. Users will always be able to prevent JavaScript running no matter how vendors show or hide advanced settings – but few will bother.

Only Microsoft Edge makes it difficult to disable JavaScript. Perhaps that’s because JavaScript has become an integral part of Windows 10 rather than an omission in Edge? If you don’t like it, you can install any other browser or use a proxy to remove .js files.

The Blink-based browsers go further and allow users to enable or disable JavaScript on a site-by-site basis. It’s a great option although even fewer people are likely to maintain URL blacklists and whitelists.

Vendors continually seek to improve performance. Despite Google’s reliance on advertising, even Chrome will shortly receive a built-in ad-blocker. The next step: could vendors block JavaScript on sites which exhibit poor performance? It’s an easy win: they just need to provide their own JavaScript-disabling blacklists much like they do with malicious sites and ad-blocking systems.

If that happens, users won’t have to manually disable JavaScript – the browser will learn from performance metrics gathered when others visit a site. Ultimately, we may be forced to use responsible scripting techniques whether we like it or not.

How to Disable JavaScript

Here’s how to disable JavaScript in the majority of modern browsers.

Google Chrome

Chrome 59 brings a sleeker set of options and you can disable JavaScript on a site-by-site basis:

  1. Visit any site then click the “site info” icon on the left of the address bar.
  2. The menu allows you to allow or block JavaScript on that site.

You can disable it globally by clicking “Site settings” from that menu or within the main settings:

  1. Select Settings from the three-dot menu icon.
  2. Scroll to the bottom and click Advanced.
  3. Click Content Settings in the Privacy and security section.
  4. Click JavaScript.
  5. Click Allowed (recommended) to change it to Block.

You can also add URLs or regular expressions to block and allow JavaScript on specific sites.

Google Chrome Mobile (Android)

A similar process is provided on the mobile edition of Chrome:

  1. Select Settings from the three-dot menu icon.
  2. Click Site settings.
  3. Click JavaScript
  4. Click Allow sites to run JavaScript (recommended) to change it to Blocked.

Once blocked, you can add URL exceptions.

Mozilla Firefox

There is no simple option within Firefox. To disable JavaScript:

  1. Type about:config in the address bar and accept any warnings.
  2. Type javascript in the Search box.
  3. Double-click javascript.enabled to change the value to false.
  4. Close the tab and restart the browser.

Safari (Mac OS)

To disable JavaScript in Safari on Mac OS:

  1. Run the browser and click Safari in the menu at the top of the screen.
  2. Choose Preferences.
  3. Click the Security tab.
  4. Uncheck the Enable JavaScript option in the Web content section.

Safari (iOS iPhone and iPad)

To disable JavaScript on the iPhone or iPad edition of Safari:

  1. Open Settings from the home screen.
  2. Scroll down and tap Safari.
  3. Tap Advanced at the bottom of the screen.
  4. Tap the JavaScript toggle button to enable or disable.

Microsoft Edge (Windows 10)

The latest release of Windows 10 does not permit you to disable JavaScript.

Some earlier editions allowed you to change settings in the Local Group Policy Editor: User Configuration > Administrative Templates > Windows Components > Microsoft Edge, then change Allows you to run scripts, like JavaScript to Disabled.

Microsoft Internet Explorer

JavaScript is enabled or disabled via the Internet Options dialog accessed from the Windows Control Panel or IE menu.

  1. Choose the Security tab.
  2. Click the Custom level… button.
  3. Scroll down to the Scripting section toward the bottom.
  4. Select Disable in Active scripting.
  5. Click OK then OK again.

Opera

To disable JavaScript in Opera:

  1. Choose Settings from the Opera icon menu.
  2. Either click Websites in the left-hand menu or type javascript in the Search settings box.
  3. Select Do not allow any site to run JavaScript.

Click Manage exceptions… to enter URLs or regular expressions which can be set to automatically allow or block JavaScript.

Vivaldi

Vivaldi runs the same Blink engine used by Chrome and Opera but you will not find JavaScript in the standard settings pane. To disable scripting:

  1. Visit any site then click the “site info” icon on the left of the address bar.
  2. The menu allows you to allow or block JavaScript on that site.

You can also configure JavaScript on a global basis:

  1. Select Site settings at the bottom of the “site info” menu to access the Blink settings.
  2. Select Do not allow any site to run JavaScript.

Click Manage exceptions… to enter URLs or regular expressions which can be set to automatically allow or block JavaScript.

Brave

To disable JavaScript in Brave:

  1. Click the Brave logo at the top-right.
  2. For single sites, set Block Scripts on.

For global settings:

  1. Click Edit default shield settings… in the pop-up.
  2. Switch to the Preferences tab.
  3. Set Block Scripts (will break many sites) on.

Alternative Options

Search your browser’s add-ons store – there are many extensions which can enable, disable, rewrite or modify JavaScript in different ways.

Most developer tools (except Edge?) permit you to disable JavaScript but it normally applies to the active tab and session only.

Conclusion

As mentioned above, the question “should users be able to disable JavaScript” has little relevance in 2017. Users will always be able to prevent JavaScript running no matter how vendors show or hide advanced settings – but few will bother. Whether we should cater to those users without JavaScript depends largely on the application you are building. Yet common sense dictates: the more accessible your content, the larger the audience you can attract.

But what do you think? I’d love to hear from you in the comments below.

This article was peer reviewed by Chris Perry, Lesley Lutomski and Matt Burnett. Thanks to all of SitePoint’s peer reviewers for making SitePoint content the best it can be!