Ask HN: Why would you disable JavaScript?

48 points by cupofjoakim ↗ HN
Base info: I'm a front end dev born in the early 90's with three years experience.

A lot of older dev's that I've worked with have told me that best practice often includes making sure that the site is usable even if you've got javascript disabled.

To me, this is completely bonkers. Are we really supposed to cater to the sub 2% that chooses not to use javascript?

To me it would make more sense to use that time to make the sites usable for visitors with disabilities by including screen reader support and stuff like that.

90 comments

[ 2.5 ms ] story [ 156 ms ] thread
Wouldn't it depend on the type of audience you're trying to appeal to?

I would imagine the amount of people disabling JS would be a lot more coming from a site like HN, compared to say, pintrest. It would be worth making sure your site functions without JS if you know a lot of your audience will be disabling JS.

I always disable JS by default. It prevents a lot of the cross-site tracking bullshit from working. And catering to users with disabilities tends to be easier when your page content is represented as page content and not dynamically loaded by JS.
Dynamically loading content has problems beyond screen readers, for stuff like SEO, so I get your point. Another guy did post this link though, showing that most screen reader users have js enabled: http://a11yproject.com/posts/myth-screen-readers-dont-use-ja...
Of course they do, or they would not be very useful given the number of horribly-built websites today, but even the JS-enabled screen readers can get confused by dynamically loaded content, sometimes getting it in the wrong order or not being able to access content that's triggered by things like infinite scrolling. Still, requiring JS for core non-interactive functionality is a net negative for any website. Why spend more effort on making your site more annoying?
I have it selectively whitelisted via NoScript, rather than just disabled. I only enable it for a domain when there's a compelling reason (i.e. it's not just for ads/trackers) and even then, the permissions will be temporary unless it's a site I frequent.

Most of the time browser security flaws rely on JavaScript in some way, so this makes me more secure by default at the expense of usability. It has a happy side-effect of disabling other random annoying things as well.

It seems there are less reasons the more time passes. I thought that screen-readers don't support javascript (imagining something like lynx), but it turns out that its a myth by now: http://a11yproject.com/posts/myth-screen-readers-dont-use-ja...
I can confirm this. Recently got a complaint from a blind user about an inaccessible form element that was buried deep deep within our JavaScript web app. We learned a couple of things that day.
The fact that screen-readers try to make sense out of JS-heavy pages does not mean that blind users wouldn't benefit if there were no JS between them and the text they want to hear.
This is exactly how you make the sites usable for visitors with disabilities -- by disabling JavaScript.

A website needs to work perfectly (if even simplistic) and make sense with all styling and dynamism disabled.

Make sure your documents makes sense when viewed in a browser like lynx. Then move on to enhance it with dynamic features (JS) and styling (CSS).

It would make sense back then when browser security was potatoes. Today, even firefox made it hard to disable Javascript. In fact, our startup website doesn't even load unless you have Javascript enabled.

Also, it's not sub 2% today, it's more like sub 0.01%.

Depends on what you're building, I guess.

For particulary security sensitive areas, like banking web software, I'd very much appreciate it working with JS disabled, since I take particular care on security when visiting those (updated, secured, sandboxed OS within VM, not used for anything else).

Good point, it sure makes sense for sites with higher security demands. I'm in the ad world though, and there's not that much security risks involved in campaign sites.
I wouldn’t. But I have Ghostery installed and in some cases it completely destroys sites. So my guess is that the 2% you're mentioning could get a bit higher. I don't know how popular utilities like Ghostery or NoScript are outside our community but I won't be surprised if their usage rises.
People should be testing what happen to their site when random resources you're pulling in don't load.

Only time ghostery breaks sites for me is when some massive 'page failed to load' element site on top of the content. I can delete those with dev tools.

For website content (landing pages, articles, etc), you want it to work without Javascript so that crawlers index it properly.

For web applications where you don't care about content being indexed, I wouldn't worry about it being a javascript only application (and this is the direction lots of apps are heading with frameworks like Ember.js, Angular.js, and Meteor).

Even in these cases there are workarounds that prerender the page and serve them to crawlers. They're not pleasant to work with, but we went with that solution on an old site we did in angular.
I think you're spot on. I've noticed working with various people and ages that we get stuck in our beliefs. Their information is outdated and they haven't realized yet that screen readers and security are dated arguments.

The only hardcore crowd who disables Javascript entirely are people who are paranoid about ads and the uber nerd (as seen here on HN).

As a web developer myself, I would never waste what busy time I have catering to this audience. It's the same argument for why, at a certain point, you have to make a clearcut decision about how far back into legacy browsers you care to support. Large parts of Asia are stuck on IE6 because they have pirated Windows XP, but most of us don't care and probably don't need to.

Thats a great question, and the answer depends on what your product is. If you are making SaaS or a web based app, then it is perfectly reasonable to require JavaScript. If you are making public websites, that display content or represent a brand, then you probably want to cater to those who don't have it enabled. Also remember it is not just the 2% that have javascript disabled that you need to consider. You should also take into account anyone who would require 508 compliance on your site. Thinking about 508 often leads to a more conscious decision on how to structure script based functionality on your page.
Because it reduces the attack surface of the browser?

Because not all search engines could cope with it (this reason now obsolete).

Because of a variety of screen readers and browsers which don't (reason also obsolete).

It's good practice to not go with batshit insane navigation, however (infinite scroll interactions with the back button, anyone?), or require JS for trivial inanities, or not have relatively meaningful URIs.

Great answer. I wouldn't couple js with insane navigation though, that's a different problem entirely (which we as a community need to shun until it disappears).
Besides security reasons, I turn it off on my mobile. 10kb of text load much faster than 500kb of javascript and some text.
A site doesn't have to work completely without JavaScript, but its a good idea to support primary flows without it and make sure your site loads and basically functions. If you are talking about a product who's features and UI require JavaScirpt then let the user know why the product can't be used and move on.
Back in the day it was also about supporting the various lo-fi web browsing devices that were around at the time. WAP on mobile phones, and TV set top boxes (Was it called WebTV? Those were the days.)

Now I agree it's only to support web fundamentalists who disable it completely, and those people surely must be used to having sites not work properly.

At the same time, if you require JS for things that don't need it, like basic navigation or dropdown menus, then that's lame for a different set of reasons.

In general, the principle of progressive enhancement is still a useful and important one. It's good to know how to make a great website in pure html and css, and then to layer the JS on top, simply because it's an effective technique that results in good code and usable websites.

It is obviously not feasible to make all full-blown web apps work without JS, but many basic websites are also packed with annoying amounts of JS that do not do the user any good (for details see the other comments).
It really depends on your audience. As a general rule, you should try to make your site allowable for javascript-disabled-noobs to still be able to go through the primary functions of your site.

With that said, out of our 1m visitors a week, we have less than 0.1% with it disabled. So it's a tradeoff - how long will it take you to code the extra to allow those 0.1%, and does this require extra code and junk up.

We don't support any browsers once it gets to below 1% - aka IE7 so I don't generally go out of my way to make sure everything works for non-javascript users.

It used to be more important back in the day with the old school mobile browsers etc with the good ol' WAP (as Jonnie says)

Well, if it's a website then it should be optional. If it's a web application then it shouldn't be. HTML and web are about linked documents after all. The fact that industry decided to slap a scripting language on top and call it GUI doesn't change the initial concept.
> Are we really supposed to cater to the sub 2% that chooses not to use javascript?

In my opinion: No.

JavaScript should be treated as default feature of the browser now. It's about as worth the effort as catering to people who want to use Lynx as their browser.

The screen reader argument is bogus too, modern screen reader software is not hampered by JS.

I also wonder if those who disable JS because of the increased attack surface also disable CSS as well.

Don't troll. CSS cannot run arbitrary code on your device.
(comment deleted)
Neither can JS, as it is sandboxed.

The interpretation and application of CSS directives is not Turing complete, but often enough to leak information from your browser.

What about those that disable js because you didn't test your js on their mobile browser and it renders the site unusable?
Turn the question around. What exactly are you providing with Javascript that is _essential_? If in the final analysis there is nothing essential, only spit-n-polish, then _why not_ cater to a broader audience by employing progressive enhancement.

In my opinion better designs would emerge from the influence of this design constraint, along with better tools and frameworks.

JavaScript allows you to use WebGL, which is essential for high-performance 3D interactive content in the browser.

Granted, not many websites need WebGL, but the ones that do need JavaScript.

I'd suggest that you've not really answered the question.

yes webGL is a nice feature, but is it required?

For example, a menu is required for navigation, however it doesn't need animations to work. Sadly there has been a trend for things that actively slowdown or hamper speedy navigation (the breaking of the back button, animated transitions etc.)

Thats not to say JS is inherently bad. but when a website sucks 90% cpu to essentially display text, there is something drastically wrong.

(comment deleted)
Why would you want "high-performance 3D interactive content" in a browser?

What I want is to read things and communicate with people.

It really depends on your product. If you have an e-commerce site, you may find that 5% of your browser base could be IE8. You still want them to spend money.

It's very much a financial decision. Who is your target market and is it reasonable to assume they will have a modern browser OR you can dictate that they have a modern browser.

You then have the issue of accessibility.

If your PC is old and you don't have much CPU or RAM to spare, disabling JavaScript gives a big performance boost.