views:

820

answers:

13

I'm currently building a project and I would like to make use of some simple javascript - I know some people have it disabled to prevent XSS and other things. Should I...

a) Use the simple javascript, those users with it disabled are missing out

b) Don't use the simple javascript, users with it enabled have to click a little more

c) Code both javascript-enabled and javascript-disabled functionality

I'm not really sure as the web is always changing, what do you recommend?

+22  A: 

Degrade gracefully - make sure the site works without JavaScript, then add bells and whistles for those with JavaScript enabled.

orip
This opinion is old school - to me, it's like saying "make your web page work for people that have HTML disabled" - JavaScript is such an integral part of the web nowadays that I can't fathom web applications without it. Web sites (i.e. not web apps) are a different story, but I still feel similarly
Jason Bunting
Jason - how we feel about users who lack a technology doesn't matter. Whether users leave in frustration does. And even those who normally use modern browsers may make their first visit from their mobile phone.
Nathan Long
If you care about accessibility, code fallbacks. They're usually not even that hard. If fallbacks were hard it would be a different story, but they're not.
singpolyma
+3  A: 

It depends on how much time you have to develop and maintain both solutions, and how much the non-javascript users are worth to you.

My e-commerce site relies heavily on javascript, and in over a year and a half, I've not received a single complaint. In fact, I don't think I've seen a single visitor with javascript disabled in any of logs since I started. That doesn't mean they're not out there. It just means that either (a) they're a tiny percentage, (b) they're not interested in what I'm selling, or (c) both of the above.

Andrew Rollings
or (d) not interested in the risk your site potentially poses. I routinely move on to a more security friendly site when I encounter one that is unnavigable due to JS being required.
kloucks
I think that falls under (a).
Andrew Rollings
+1  A: 

It is essential to at least test your website is functional when JavaScript is turned off.

As orip says, degrading gracefully is very important. It should be vital that your page both looks nice and functions when JavaScript is disabled.

adam
+12  A: 

Consider your audience

"Degrade gracefully" is generally the best answer. But lots of sites now depend on JS - especially AJAX.

Consider your audience. If your site is aimed at extremely tech-savvy people, the chances of them not having javascript are small, and you can notify them to turn it on if necessary.

If your audience may access your site with mobile devices, don't assume they have JavaScript, and don't even assume they support CSS properly. Aim to degrade gracefully all the way down to bare HTML.

Nathan Long
I find the opposite to be true. Usually tech savvy people have javascript turned off, because they are aware of the dangers, and how to turn it off. Regular Joes don't know about the dangers, and even if they did, wouldn't know how to turn it off.
Kibbee
@Kibbee, depends how far on the scale, the real hard core geeks disable security because their system/way of working is impervious to security flaws/information leaks :P
Kent Fredric
A: 

I don't care if people disable javascript, to bad if the page doesnt run as its suppose to. It's the same with cookies.

There's like 2% not using Javascript, so why bother, economic wise i'd just dev. the javascript solution.

Filip Ekberg
NoScript Extension exists, and is popular. Enough said.
Kent Fredric
And then there's the 2% with IE5, and the 2% with Cookies, and the 2% with dial up, and the 2% ... well I think you get the picture. Cut off all the 2% users, and you are cutting out a big percentage of users when they are all added up.
Kibbee
By that logic, we should all make sure our site runs on IE and ignore Firefox.
Graeme Perrow
Google for "innumeracy". 2% of A + 2% of B + 2% of C = 2% of total.
le dorfier
And the 2% with A turned off are the same people with the rest turned off.
le dorfier
Now now, don't take that percentage too serious :)I've never really seen any point in disabeling javascript totally, i nowdays use Chrome and this has a smart javascript blocker, so i dont need to turn everything off. As Benry said "95%-97% of potential users will have JavaScript enabled."
Filip Ekberg
+3  A: 

As other have said, it should "degrade gracefully".

In other works, it must work without Javascript (period). It doesn't have to work well. The folks who've disabled Javascript know the limitations that causes and have accepted them. But if you are trying to sell them something, it's important that they can still buy it.

On the site I'm designing, there's a javascript-based fly-out menu. With Javascript off, all the flyouts are always open. It doesn't look as cool as it would with JS, but it can still be used to navigate the site.

James Curran
A: 

As said before, it depends on your target audience.

If I'm part of it, you want to make sure that your site works (if not ideally) on my phone, and that it gives me reason to turn Javascript on when I surf there with it off. Nobody expects full functionality with Javascript disabled, and anybody who uses their phone to access websites expects some issues, but you need to at least provide teasers. For a web store, make sure customers can see at least some merchandise anyway, even if they can't buy without Javascript.

David Thornley
+2  A: 

I am one of those that uses 'No-Script.' And I can tell you that sites that use javascript and don't work without it enabled is extremely annoying, stackOverflow... No we don't expect it to be very fancy, if I upvote load a new page that says "Thank you."

We expect to be able to use the site with reasonable limitations, don't ever display a page that says JS must be enabled, though, even if the site is crap without it. And yes if your site convinces us to stay we will enable. A function that isn't in common use on the site can also require javascript.

Please note that your site should also look good with no JS or CSS, if nothing else it is good for Bots.

As others have pointed out some phones don't have JS, this is changing but another good reason to have reasonable non-JS. I suggest code with non-JS and add JS after the former works, there are good ways where JS can work with the non-JS layout.

he_the_great
+12  A: 

Everyone else has committed good comments, but there are a few other considerations to make.

Sometimes the javascript will be hosted on a different domain, and be prone to timeout.

Sometimes that domain may become inacessible, while your site remains accessible. Its not good to have your site completely stack itself in this scenario.

For this reason, "blocking" scripts ( ie: document write inline ) like that present in google's tracker, should be avoided, or at very least, should go as late in the page as possible so the page renders whether or not the domain is timing out requests or not.

If you happen to be serving JS from a broken/malicious server, by intent or by accident, one can halt page rendering simply by having a script that serves that javascript which just calls "sleep(forever)" once its sent all the headers.

Some People Use NoScript

Like the above problem, sometimes the clients environment may block certain script sources, be it the users choosing, or other reasons ( ie: browser security satisfactions, odd antivirus/anti-malware apps ). The most popular and controllable instance of this is NoScript, and I myself paranoidly block some of the popular tracking/advertising services with it ( some proxy servers will do this too ).

However, if a site is not well designed, the failing of one script to load still executes code that was dependant on that script being present, which yeilds errors and stops everything working.

My recommendation is :

  1. Use Firebug
  2. Use NoScript and block out everything --> See Site still works
  3. Enable core site scripts that you cant' do without for anything --> See site still works and firebug doesn't whine.
  4. Enable 3rd party stuff --> See site still works and firebug doesn't whine.

There are a lot of other complications that can crop up, but satisfying the above 2 should solve most of them. Just assume that, for whatever reason, one or more resources that comprise a page are viable to spontaneously disappear ( they do, all the time ), and you want the page to "survive" this problem as amicably as possible. For the problems that may persist for < 10 seconds, its not so bad, refresh the page and its fixed, but if its a problem that can occur, and severley hamper usability for an hour or more at a time.

In essence, instead of thinking "oh, theres the edge case users that don't have javascript", try thinking more a long the lines of "its really easy to have something go wrong, and have ALL of our users with broken javascript. Ouch! Lets try make it so we dont' really hose ourself when that does happen"

( I've seen IE updates get rolled out and hose javascript for that entire browser until the people whom wrote the scripts find a workaround. Losing all your IE customers is not a good thing )

:set sarcasm

:set ignoreSpelling

:set iq=76

Don't worry, its only a 5% Niché Market

Nobody cares about targeting Niché markets right? All those funny propeller heads running lynx in their geeky stupid linoox cpus, spending all their time on the intarwebs surfing because they have nothing better to do with their life or money? the crazy security paranoid nerds disabling javascript left and right because they don't like it?

Nobody wants them as your primary customer now do they? Niché markets. Pfft. Who cares!

:set nosarcasm

Kent Fredric
You forgot to `set` your `iq` and `spelling` back to normal, -1.
Baddie
+1  A: 

For a standard web site that is primarily intended for conveying information, degrade gracefully always.

For web applications:

When building a web application for a standard internet audience, I would keep the three following facts in mind:

  1. 95%-97% of potential users will have JavaScript enabled.
  2. At times established users will need to access functionality when JavaScript is not available.
  3. 3%-5% of potential users will have JavaScript intentionally disabled.

Given fact one, if you believe that building a JavaScript reliant web application will deliver a superior user experience, then by all means do it. Doing so may help you accumulate users.

However, given fact two, you should always provide a means by which your users can access core functionality without JavaScript. Do you need to offer every single feature? Probably not. But a user should be able to get his or her work done. This will keep your users happy when they find themselves temporarily without JavaScript.

Given fact three, I would also provide an in depth tour as an attempt to entice these users to enable JavaScript.

As an aside, one of my most favorite web applications, Remember The Milk follows this approach. Also, Google's Calendar application is unusable without JavaScript. So JavaScript reliant web apps are on the rise and that trend is probably unstoppable. In my opinion this is a good thing.

(Do keep in mind that JavaScript make Accessbility a bigger problem than it is already. Please do make an effort to make your apps usable by those with disabilities.)

Benry
+3  A: 

Code your web site with support for the bare minimum kind of browser. Then more people can use your site without frustration even if they don't have all the bells and whistles--like Flash, Javascript, and Java--enabled. It may not be practical to continue support for ancient browsers, say Netscape Navigator 4, because a user can be reasonably expected to keep their computer up-to-date. However, features like Javascript, Flash, and Java can be security holes in old or modern browsers, as well as being an annoyance.

Neither of my parents keep Javascript or Flash enabled because they've had too many experiences with them slowing down their already slow connection, crashing their browsers, or being more of an annoyance on sites that use it stupidly (which is a lot of them...) than a useful feature. It's just bad design if, for example, your form requires an AJAX call be made and you can't actually hit a submit button to send the form when Javascript is disabled.

My mother was recently quite frustrated to discover that she is now unable to click through eBay results pages because each one requires Javascript. The only way she can see the next page of results is to turn on Javascript or to show more results per page. Now what reason would there be for page links to require Javascript while the 'results per page' links are just plain links? They should all be plain old HTML links. Maybe Javascript could be used to add some whiz-bang to the navigation, but a user should not be punished with a bad interface for having Javascript disabled. It's stupid on eBay's part, and it causes undue hassle for their users.

Sarah Vessels
+1  A: 

I've learned a lot from my question: What's With Those Do-Not-Use Javascript People

Go with Ajax and Web 2.0. It's the way the web is going and it's wonderful. Isn't Stackoverflow great to be on? It's not quite as nice with your Javascript turned off.

Once you have your site ready, but before you let it go live, test it with Javascript off, and just add whatever you feel you need to make your site appear and function to them. You only need to add what you feel is essential.

Remember, except for visually impared people using screen readers, the others have chosen to turn javascript off. They can also choose to trust your site and turn javascript on for your site if they want to use all the functionality you have. It really is their choice.

lkessler
A: 

It helps me in my implementations to think about it as "progressive enhancement" rather than graceful degradation. Degradation often leads you to figure out how to make it work w/o js after it is implemented, instead of making a baseline and enhancing with js.

jayrdub