What do you do if your site visitors have JavaScript disabled?
Asked Answered
J

9

5

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

Jacy answered 26/1, 2010 at 16:39 Comment(5)
Redirect to goatse, of course. :)Munch
Insert something to have them turn the annoying JS on. Like content ;)Pu
@Munch - how do you redirect when Javascript isn't enabled?Frigidarium
Display an html link of course!Grave
What kind of site is it? Mainly static pages to read or AJAX-heavy? Web 1 or 2.0?Destinydestitute
C
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.

Croaker answered 26/1, 2010 at 16:46 Comment(1)
Note that even Google Maps, the posterchild of javascript interactivity, works with javascript turned off! Try it.Hereat
L
14

you would degrade gracefully.

Larsen answered 26/1, 2010 at 16:41 Comment(1)
I disagree, you should use progressive enhancement.Croaker
F
10

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

Fathead answered 26/1, 2010 at 16:43 Comment(10)
Why is this +4 and I got -1 for same answer earlier.Frigidarium
Downvoters hardly post their reasons for a downvote, I'd be surprised if you get an answer as to why.Grave
@Anthony - thanks. To be honest, Im about ready to give up on Stackoverflow. Am I being petty?Frigidarium
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? :/Grave
@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".Joyjoya
@Ian - Much appreciated, I will indeed return the favor once my limit is reached.Grave
@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?Weak
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?Lanchow
@Ed totally agree and a -ve score is people saying I'm an idiot, people who upvotes the first thing they recognize as correct.Frigidarium
-1: Dup #2141378Cichlid
F
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.)

Frigidarium answered 26/1, 2010 at 16:42 Comment(5)
I'd have to come back in 6 hours to save this answer. :/Grave
-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.Joyjoya
@David I'm guessing that someone would put their own message in there. I've added a disclaimer to my answer for you.Frigidarium
@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.Battery
@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.Frigidarium
T
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')

Trinh answered 26/1, 2010 at 16:50 Comment(2)
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)Joyjoya
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.Trinh
G
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.

Grave answered 26/1, 2010 at 16:43 Comment(0)
G
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...

Gravelly answered 26/1, 2010 at 16:51 Comment(1)
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?Battery
E
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>
Ellipsis answered 26/1, 2010 at 16:44 Comment(1)
-1. Don't upvote because people have downvoted for reasons which should be obvious from the comments on duplicate answers.Joyjoya
A
0

you can check this out:

How to detect if JavaScript is disabled?

Amplexicaul answered 26/1, 2010 at 16:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.