views:

393

answers:

9

What would you do if your site visitors disabled JavaScript? Do you block them?

+14  A: 

you would degrade gracefully.

SilentGhost
I disagree, you should use progressive enhancement.
easement
+4  A: 

Use the NoScript tag to say "Hey, Enable Javascript fool!"

<script type="text/javascript">
       alert("Hello World!");
</script>
<noscript> 
       Hey, Enable Javascript fool!
</noscript>

(Please note that this is code is not ready deployment to your website. You can change the message to something more suitable than plain text.)

Dead account
Isn't there a comma missing?
Leonidas
There was a semicolon missing, I edited it.
Anthony Forloney
+1 because this answer doesn't deserve a negative vote.
rlb.usa
I'd have to come back in 6 hours to save this answer. :/
Anthony Forloney
-1. Calling someone a fool and ordering them to enable JavaScript in a world where (1) a large proportion of security vulnerabilities on desktops come through JavaScript engines in browsers and (2) when JS is disabled, it is often beyond the control of the user (because the JS was blocked by a sysadmin) is, frankly, offensive.
David Dorward
@David I'm guessing that someone would put their own message in there. I've added a disclaimer to my answer for you.
Dead account
@Ian: However, you're still not addressing the basic issue: why should I enable Javascript for your site (either by telling NoScript it's OK or talking to an admin)? While there are sites with captive audiences, most want to attract visitors, and ordering them around is likely to drive them away.
David Thornley
@David Thornley; my answer is "the NoScript tag can be used to display information when JavaScript is disabled". It's not an alternative to the "degrade gracefully" answers and I wouldn't copy or repeat someone elses answer. As for ordering them around and captive audiences, well that's nothing to do with the question. Is the question "how to make a site with and without Javascript?" No.
Dead account
+1  A: 

Your website should be somewhat prepared if JavaScript is disabled, either display a message that your website works better with JavaScript enabled or work-around it.

Anthony Forloney
+10  A: 

Indeed degrade gracefully. If that's not an option (anymore ;-)) then at least notify them with utilizing a <noscript> tag.

fireeyedboy
Why is this +4 and I got -1 for same answer earlier.
Dead account
Downvoters hardly post their reasons for a downvote, I'd be surprised if you get an answer as to why.
Anthony Forloney
@Anthony - thanks. To be honest, Im about ready to give up on Stackoverflow. Am I being petty?
Dead account
Nope, I share the same feelings. What grinds my gears is when I post the only answer after mere seconds to a question and the author barely checks it. Whats the point in posting a question if you never check it? :/
Anthony Forloney
@Ian - probably because you went to noscript, directly to noscript, do not pass an accessible version, do not degrade gracefully. Here the noscript is a secondary option associated with "If that's not an option".
David Dorward
@Ian - Much appreciated, I will indeed return the favor once my limit is reached.
Anthony Forloney
@Ian, so did Trevor, and rashid, below. Their answer's aren't [i]wrong[/i], I don't think they should have a negative either. What's going on here?
rlb.usa
Perhaps you should worry less about the voting system. I know that we all like getting those shiny points, but really we are here to learn, no?
Ed Swangren
@Ed totally agree and a -ve score is people saying I'm an idiot, people who upvotes the first thing they recognize as correct.
Dead account
@David did you downvote this too?
Dead account
-1: Dup http://stackoverflow.com/questions/2140878/what-do-you-do-if-your-site-visitors-have-javascript-disabled/2140918#2140918
Ruben Bartelink
A: 

If your visitors didn't know they have JavaScript disabled, a simple message would let them know they should enable it.

<noscript>Please enable JavaScript in your browser</noscript>
Trevor
+1. Don't downvote without reason ppl!
Dead account
-1. Don't upvote because people have downvoted for reasons which should be obvious from the comments on duplicate answers.
David Dorward
A: 

you can check this out:

How to detect if JavaScript is disabled?

rashid
+12  A: 

Ideally, you would use progressive enhancement which entails guaranteeing a base user experience and then adding all the flourishes for browsers that can handle them.

easement
+1 for doing it the right way.
slebetman
Note that even Google Maps, the posterchild of javascript interactivity, works with javascript turned off! Try it.
slebetman
+2  A: 

To couple with <noscript> I have all elements that require JS to function with class="js-required".

Then CSS: .js-required{display:none;}

JS on page load: $('.js-required').css('display','block')

Raveren
If JS is needed, then I'd generate them using JS and not depend on CSS to conceal them. (e.g. search engines will still pick them up)
David Dorward
it's fine SE pick them up as the elements do have a role and are usually visible (like rich submit buttons etc) it's only when JS is disabled are they hidden.
Raveren
+1  A: 

For every site I build, I compare the cost of development for degrading gracefully, versus the loss of income by scaring off ~2-3% of the audience. Not caring about non-javascripters/Opera/etc usually wins...

truppo
How do you get 2-3% of the audience, as a matter of curiosity? How confident are you that the absolute numbers (which is usually what matters) of people you annoy will stay low enough over the life of the website? How do you tell whether NoScripters et al. represent a more or less important demographic for your site?
David Thornley