5

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

Neil Aitken
  • 7,856
  • 3
  • 41
  • 40
streetparade
  • 32,000
  • 37
  • 101
  • 123

9 Answers9

15

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
  • 6,119
  • 3
  • 29
  • 36
  • 2
    Note that even Google Maps, the posterchild of javascript interactivity, works with javascript turned off! Try it. – slebetman Jan 26 '10 at 16:57
14

you would degrade gracefully.

SilentGhost
  • 307,395
  • 66
  • 306
  • 293
10

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

Decent Dabbler
  • 22,532
  • 8
  • 74
  • 106
  • Why is this +4 and I got -1 for same answer earlier. – Dead account Jan 26 '10 at 16:47
  • Downvoters hardly post their reasons for a downvote, I'd be surprised if you get an answer as to why. – Anthony Forloney Jan 26 '10 at 16:48
  • @Anthony - thanks. To be honest, Im about ready to give up on Stackoverflow. Am I being petty? – Dead account Jan 26 '10 at 16:50
  • 1
    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 Jan 26 '10 at 16:51
  • 2
    @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". – Quentin Jan 26 '10 at 16:52
  • @Ian - Much appreciated, I will indeed return the favor once my limit is reached. – Anthony Forloney Jan 26 '10 at 16:59
  • @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 Jan 26 '10 at 16:59
  • 1
    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 S. Jan 26 '10 at 16:59
  • @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 Jan 26 '10 at 17:12
  • -1: Dup http://stackoverflow.com/questions/2140878/what-do-you-do-if-your-site-visitors-have-javascript-disabled/2140918#2140918 – Ruben Bartelink Jan 26 '10 at 17:16
3

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
  • 19,587
  • 13
  • 52
  • 82
  • I'd have to come back in 6 hours to save this answer. :/ – Anthony Forloney Jan 26 '10 at 17:00
  • 1
    -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. – Quentin Jan 26 '10 at 17:00
  • 6
    @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 Jan 26 '10 at 17:08
  • 1
    @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 Jan 26 '10 at 17:21
  • @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 Jan 26 '10 at 20:48
2

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
  • 17,799
  • 12
  • 70
  • 83
  • 1
    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) – Quentin Jan 26 '10 at 16:53
  • 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 Jan 26 '10 at 17:01
1

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
  • 90,123
  • 14
  • 117
  • 115
1

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

mthurlin
  • 26,247
  • 4
  • 39
  • 46
  • 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 Jan 26 '10 at 17:26
0

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
  • 6,659
  • 5
  • 35
  • 68
  • 1
    -1. Don't upvote because people have downvoted for reasons which should be obvious from the comments on duplicate answers. – Quentin Jan 26 '10 at 16:56
0

you can check this out:

How to detect if JavaScript is disabled?

Community
  • 1
  • 1
infinitloop
  • 2,863
  • 7
  • 38
  • 55