Close

July 5, 2017

Should Users be Permitted to Disable JavaScript?

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 somethingand 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”.

July 5, 2017