I have been trying to figure out whether or not to use javascript on websites I work on. I know there are people who have it disabled thus it would be bad to use.
I would like to do some drop down menus but everything seems to be javascript or some really overly complex css script.
So where do you stand on the issue of Javascript on websites.
Avoid at all costs?
Suck it up and have alternatives alongside?
Require people to have it enabled?
Maybe there are some javascript functions that will always work?
Any insights or websites linked on the matter are appreciated. thanks 
Its 2007, the only people who have it disabled are people who visit "special" sites.
I'd just say let them suck it up. There's always going to be one person still with javascript disabled, and we can't let them slow the rest of the internet down.
It's not only people who visit "special" sites that has it turned off, stuiped statement.
However, there are plenty of drop down menus done with just css that works great, just browse this forum (the html part) and you'll find a post by myself, posted a dropdown menu build with css only, also called suckerfish dropdown.
I think of javascript this way, I only use it when css can't do it and I absolutley need it (that's more or less never)
The main use of javascript these days, apart from mouseover effects for menus etc, is that it gives developers access to the DOM. This enables them to manipulate elements on a page by moving them, show/hide them, changing zIndex etc, to load specific css stylesheets using browser sniffing techniques etc. All these things can be achieved using PHP or other server side programming, but not everyone, including myself, is quite up to speed on this yet.
It is also client side, meaning it's generally faster.
One disadvantage is that it generates more work for developers if they wish it to work in non-javascript enabled browsers. Very few people have javascript disabled these days anyway. People prefer to allow it. If a site is overloaded with javascript, with no warnings to the visitor that javascript is required for some functionality etc, then they simply don't come back to the site.
i only use javascript for serten things like showing the date and updatingtime things like that but what ido is i put anotes on themainpage saing that some things need javascript inabled towork. andlive up to the visiter if they want toinableitor not
I think you're fine using Javascript as long as you follow the concept of "degrades gracefully". This means, if the user has scripting off, or the browser is incompatible for some reason, the page should load properly. Maybe they won't be able to do everything as easily as people with scripting could, or things won't look as pretty, but the page itself still works properly.
| Azmo wrote: |
| It's not only people who visit "special" sites that has it turned off, stuiped statement. |
So why would anyone have javascript turned off? and who?
| Quote: |
| However, there are plenty of drop down menus done with just css that works great, just browse this forum (the html part) and you'll find a post by myself, posted a dropdown menu build with css only, also called suckerfish dropdown. |
Can you use the facy fading techniquies that you can use in javascript?
| Quote: |
| I think of javascript this way, I only use it when css can't do it and I absolutley need it (that's more or less never) |
Its almost impossible to avoid javascript these days, and if your site doesn't have it, then it lacks behind (Nearly every forum software uses it, Google's Adsense uses it, Web 2.0 App's use it.....)
There is one simple rule : all content and features of your website must be available without javascript (even if, of course, it will be less eye-candy)
And don't think everybody use javascript nowadays (hint : text browsers and search engine bots don't have javascript.)
It's a trade off...
Suckerfish dropdowns use js. To fix problems for MSIE.
The main idea is that you'll never find a perfect combination. Most of the time you will have to make a certain compromise. Using Flash to get rid of javascript (for menus, clocks, etc) will be bad for text browsers or people with visual impairments (accessibility issues). Using JS doesn't guarantee the users see what you want him to see (since JS may be turned off). CSS (for dropdown menus) may not work on all browsers, etc.
However there are ways to get as close as you can to a fully cross-browser all compatible site.
Most of browsers will tell you if they can process JS... I think the "get_browser" function allowed you to check for this. In case they don't handle JS, try with flash. In case you can't do it with flash, the use the old fashion pure HTML (or XHTML).
I have javascript turned off as default, to avoid annoying surprises. And I whitelist sites I trust (f.ex. FriHost which requires javascript because of the rules). And the sites I visit are pretty normal.
JavaScript can make a site very user friendly. But if the site do not work without JavaScript (f.ex. missing content or menu), you have gone to far. If you want to use JavaScript in your menu, go ahead and do so. You can make a nice plain menu and put between <noscript>and</noscript> and everybody's happy and can navigate on your site.
If you have some feature on your homepage that is impossible to use without JavaScript, you should tell the visitor what he is missing out on, and suggest he turns JS on for your site (do this inside the noscript-tag).
| cavey wrote: |
| If you have some feature on your homepage that is impossible to use without JavaScript, you should tell the visitor what he is missing out on, and suggest he turns JS on for your site (do this inside the noscript-tag). |
The <noscript> tag is being deprecated in the new version of HTML (or xHTML, I'm not sure)
| garionw wrote: |
| Azmo wrote: | | It's not only people who visit "special" sites that has it turned off, stuiped statement. |
So why would anyone have javascript turned off? and who? |
Ehm, because it can be realy anoying sometimes? I would get alot of pop-ups and other javascript related shit if I had it turned on, just browsing news sites.. so don't acuse people for watching porn just because they have js turned off
| Quote: |
| However, there are plenty of drop down menus done with just css that works great, just browse this forum (the html part) and you'll find a post by myself, posted a dropdown menu build with css only, also called suckerfish dropdown. |
Can you use the facy fading techniquies that you can use in javascript?[/quote]
yes, you can use the fading techniquies, lol didn't you know that? it's a style, means it can be done in css..
| Quote: |
| I think of javascript this way, I only use it when css can't do it and I absolutley need it (that's more or less never) |
Its almost impossible to avoid javascript these days, and if your site doesn't have it, then it lacks behind (Nearly every forum software uses it, Google's Adsense uses it, Web 2.0 App's use it.....)[/quote]
Ok, here is something fun, working with webdesign, and co-operating with other proffesionals, and the rule of thumb is "avoid it if you can" we are working for the whole wide web, and someone who have js turned off, might leave the site because it's not made for him, he have to activate it and stuff to be able to view it. Think of everyone when you create something, and for God's sake, google some before you make your statments.
I think javascript is fine to use considering that most people do have it enabled. The few that don't can suffer. Just make sure that when you use it, it isn't buggy code and that it will work for the majority of people. Also don't use it when it isn't needed, client side code can some times make a website become bad when it is flooded with stupid little things like crap following the cursor.
| Azmo wrote: |
| Ehm, because it can be realy anoying sometimes? I would get alot of pop-ups and other javascript related stuff if I had it turned on, just browsing news sites.. so don't acuse people for watching porn just because they have js turned off |
You haven't heard of a popup blocker before?
You'd rather manually enter your BB Code in, then click a link
You don't use Digg
You use the Basic version of Gmail/Live Mail
You don't use Youtube
or Yahoo answers
If its for something as simple as a site about our solar system, by all means go without Javascript, but if you want a blog, or designing a social site, use Javascripts. Only very few people have javascript disabled (In January this year, only 6% of people had it disabled)
Its estimated that 1.133 billion use the internet as of June 10, that means that just over 60,000,000 (60 Million) people have it disabled. Thats not many when you think of it. And just out of curiosity, can you give me a link as to where your "CSS Menu that fades in and out without the need for javascript" is? I can't seem to find it.
I don't have a site up that's using a fading script, but if you would spend 2minutes of your time on google, you shouldnt have to ask..this is where I learned to use fade... just scroll down and you'll see the "Opacity with onmouseover and onmouseout" part
I try to use as less javascript as possible. If decide to use it I try to make it work good also for thous who have javascript disabled. Myself I often have javascript disabled.
| Azmo wrote: |
| I don't have a site up that's using a fading script, but if you would spend 2minutes of your time on google, you shouldnt have to ask..this is where I learned to use fade... just scroll down and you'll see the "Opacity with onmouseover and onmouseout" part |
| Quote: |
| <div class="transOFF" onmouseover="this.className='transON'" onmouseout="this.className='transOFF'"><p style="padding:5px;width:75%;">Hover here. The Filter Opacity works in Mozilla and IE. It also works in current versions of Opera.</p></div> |
Thats what you call javascript 
| garionw wrote: |
| Azmo wrote: | | I don't have a site up that's using a fading script, but if you would spend 2minutes of your time on google, you shouldnt have to ask..this is where I learned to use fade... just scroll down and you'll see the "Opacity with onmouseover and onmouseout" part |
| Quote: | | <div class="transOFF" onmouseover="this.className='transON'" onmouseout="this.className='transOFF'"><p style="padding:5px;width:75%;">Hover here. The Filter Opacity works in Mozilla and IE. It also works in current versions of Opera.</p></div> |
Thats what you call javascript  |
My fault, didn't scroll far down enough when I copy/paste the titel.. however.. this is what I call css, since the onmouseover isn't needed.
| Code: |
<style type="text/css">
a.linkopacity img {
filter:alpha(opacity=50);
-moz-opacity: 0.5;
opacity: 0.5;}
a.linkopacity:hover img {
filter:alpha(opacity=100);
-moz-opacity: 1.0;
opacity: 1.0;
}
</style> |
Give me javascript any day. I guess I'll use Javascript because there are so many things that can't be done without it.
And it's the concept of "degrades gracefully" that should be followed.
It's not that hard to turn on Javascript either - just put a promise in your noscript that you'll not use javascript on your page to do anything annoying (popups and alert boxes and user info and stealing focus - I really hates sites which do that) and tell the user how to enable javascript.
I know I would enable javascript for a site if it asked me nicely.
Now, flash is where the big question comes for me ...
Javascript rocks in client scripting ... (but css of course rocks in the design aspect)
As long as all the features you provide is available on a non-javascript version too usage is justified. There are many users who've disabled javascript or not use it at all (Eg: Many a times i use a text browser for fast brwsing experience).
But most of the eye candy features can be achieved through css also.
| FunDa wrote: |
| and tell the user how to enable javascript. |
Oh... tell me then how to enable it in Lynx, W3M or elinks. Explain me how you would tell googlebot to enable it. And what about users at work in companies where javascript is forbidden by their administrator : how could you help them ? 
| Ranfaroth wrote: |
| FunDa wrote: | | and tell the user how to enable javascript. | Oh... tell me then how to enable it in Lynx, W3M or elinks. Explain me how you would tell googlebot to enable it. And what about users at work in companies where javascript is forbidden by their administrator : how could you help them ?  |
that pretty much goes with what I said earlier, "if you can avoid it, do it" or something like that. but as garionw, it's only people who are browsing those aduld sites that have it turned off....
anyways, I don't know how to enable it in Lynx, doesnt realy matter since I'm not using it tho, but people only think PC and IE/firefox.. ok most people use those, but alot of people don't..
Realy agree with your post and your point!
| Azmo wrote: |
| that pretty much goes with what I said earlier |
Yes, but some people appear to don't read the full thread before answering (there are two many stupid message claiming "You shouldn't care about non-javascript users")... | Quote: |
| anyways, I don't know how to enable it in Lynx |
It's simple : you can't 
| Ranfaroth wrote: |
| Quote: | | anyways, I don't know how to enable it in Lynx | It's simple : you can't  |
ah hehe, can't be any easier then that 
Like every web technology, Javascript has its uses. The key is knowing when to use it and when not to use it. Creating gratuitous drop-down menus - no. But simple roll-over effects that would not prevent the navigation working well if they weren't there - absolutely fine.
Ok . OK ...
Didn't know that people use text browsers like Lynx for browsing nowadays .. (i just used it once for seeing through the eyes of bots ... somebody told me that's how your site looks like to bots)
Then, of course I agree, I would have to put up a separate set of pages for text browsers - smaller files too (so that the faster browsing is even faster)
Cheers ...
| garionw wrote: |
| cavey wrote: | | If you have some feature on your homepage that is impossible to use without JavaScript, you should tell the visitor what he is missing out on, and suggest he turns JS on for your site (do this inside the noscript-tag). |
The <noscript> tag is being deprecated in the new version of HTML (or xHTML, I'm not sure) |
I would very much like to see you back up that, with a link to some documentation.
<noscript> shouldn't be deprecated. That is a very important tag. Like people said earlier., it would be easier to degrade gracefully if there is a noscript.
And that is a must.
| FunDa wrote: |
| Like people said earlier., it would be easier to degrade gracefully if there is a noscript. |
No.
If you use noscript, you add content, so it doesn't degrade gracefully.
This is how a web page must be written :
First : content. This is what is important, for all users. (It's in XHTML)
Then, you add (in another file), the style and layout (in CSS).
Without this file, the content is still available.
And you can add dynamic effect (in other files too), with javascript.
If javascript isn't available, the content is obviously still available. And no need for noscript (even if this element is totally valid).
Read the point 2 of this good article.
I've always said it's best to design a web page like a word document with a content list or index to begin with. Make it look good in a text only browser (or use the Web Developer Toolbar for Firefox to turn off images).
Then add CSS for styling and splitting the content from the content/index list (i.e. navigation).
Then add the flashy stuff afterwards.
It's really easy to quote the "rules" about (not) using JS, but you obviously know them already, but are still feeling your way around how to put things together.
I think your dropdown menus are a great example.
You can make a very nice dropdown menu using CSS (which can still be turned off, but it is highly unlikely) Or you could use JS (which may well be turned off) Obviously, CSS is the better choice.
(Not sure it's the better choice? How badly do you want your visitors to see your site? If it's an important feature, like navgation, and you have a way of guaranteeing they can see all of your content, are you willing to risk it?)
In either case, you will need to construct your menu in such a way that ALL OF YOUR PAGES ARE ACCESSIBLE even if CSS AND JS are (oddly) turned off.
In other words, use lists instead of tables, and makes sure that the first item in your list (which will trigger the dropdown on hover) is a link which takes your visitor to a page that includes all the links on the dropdown. SO if everything is disabled and the dropdown doesn't display, your site still makes sense.
Maybe it's all elementary and obvious stuff. And maybe it only affects a couple of users.
But, IMO, I just can't justify styling your site in a way that makes it entirely useless to a portion of your users when there is such an easy alternative.
</rant> $.02
| FunDa wrote: |
| <noscript> shouldn't be deprecated. |
The fact that it doesn't work in several browser versions (I forget which) is good enough reason not to use it anyway.
| cavey wrote: |
| I would very much like to see you back up that, with a link to some documentation. |
It was a story on digg, I can't find it now
Can someone please show me one of these CSS Only menus without using javascript, no matter how hard I search, I can't find one.
Or are they made use of htc file?
I use javascript because of all the features and uses that it has.... but I use it to a very minimal amount and everything that I use shouldn't cause people problems... I use the confirm thing on some links sometimes...
| garionw wrote: |
Can someone please show me one of these CSS Only menus without using javascript, no matter how hard I search, I can't find one.
Or are they made use of htc file? |
Me too ... I don't know how to create drop down menus using only css ...
I used Zen Cart to build my site. I have no idea whether or not it uses Java - I can't find any evidence of it.
There'll inevitably be some pages that won't be possible with Zen Cart. At that time I'll have to evaluate and decide on the best solution within my current or potential abilities.
One major factor will be ensuring that all content is available to as many search engines as possible. My current understanding is that Java content is not available to any search engine. If I verify this to be true Java is not a likely candidate as the solution to any of my problems.
A second important factor, in this decision, will be that I want my service to be available to as many people as possible. Many of my users will have little or no knowledge of, or desire to, download and install software on demand. The site must work 'out of the box' with no risk of some pop-up saying 'This site requires Java version 999.3.6.5a/7b (Sun version) - please download it from this mirror, restart your browser, then return to the site to see if that has fixed the problem'. You can, perhaps, tell that such things really annoy me! 
| GSIS wrote: |
I used Zen Cart to build my site. I have no idea whether or not it uses Java - I can't find any evidence of it.
There'll inevitably be some pages that won't be possible with Zen Cart. At that time I'll have to evaluate and decide on the best solution within my current or potential abilities.
One major factor will be ensuring that all content is available to as many search engines as possible. My current understanding is that Java content is not available to any search engine. If I verify this to be true Java is not a likely candidate as the solution to any of my problems.
A second important factor, in this decision, will be that I want my service to be available to as many people as possible. Many of my users will have little or no knowledge of, or desire to, download and install software on demand. The site must work 'out of the box' with no risk of some pop-up saying 'This site requires Java version 999.3.6.5a/7b (Sun version) - please download it from this mirror, restart your browser, then return to the site to see if that has fixed the problem'. You can, perhaps, tell that such things really annoy me!  |
Just a little head's up, we're talking about Javascript, not Java 
| coeus wrote: |
I have been trying to figure out whether or not to use javascript on websites I work on. I know there are people who have it disabled thus it would be bad to use.
I would like to do some drop down menus but everything seems to be javascript or some really overly complex css script.
So where do you stand on the issue of Javascript on websites.
Avoid at all costs?
Suck it up and have alternatives alongside?
Require people to have it enabled?
Maybe there are some javascript functions that will always work?
Any insights or websites linked on the matter are appreciated. thanks  |
Well, hi there!
Here a site with a lot of genial css tricks. I thought that I needed JavaScript for this affects till I saw this. I would say take a look by yourself!
Here the site link.
It's amazing what he did with css. A lot of good alternatives in stead of using JavaScript.
I hate JavaScript personally seen, but sometimes you just have to use it on sites.
WOLFie.
Wow, Wolfie, that's just brilliant !
I never knew that css was that powerful - I thought that css was just another way to write cleaner html - nothing more (more like pulling out all javascript into a .js file)
If css can do all this, wow , CSS is definitely Cool and Sexy Styling !!!

I have a certain add-on with firefox that disables javascript from all websites unless I allow them and most sites I visit I can still get to the content with out the site allowed. I find it prevents alot of tracking cookies from getting on my system. There are occasional sites where I need it allowed but other. What really annoys me is the sites that don't tell you, you need javascript enables so you find this like bug in a site the links won't work or whatever I usually enable the site when something like that happens and it works but. Ya if your using javascript and a major function on your site requires javascript please add in a warning saying it needs to be enabled when it detects it's not.
That would be NoScript - the firefox addon that you were talking about.
It blocks everything by default, unless u tell it to activate scripts.
I find it a bit tooo restrictive but at the same time very safe as no scripts are allowed to run.
In these cases, the CSS would definitely outshine anything else in bringing out the site design as the creator intended.
Firefox has so many addons - many of which restrict javascript and people are shifting to script blockers, so CSS is the way to go...
NoScript is a great extension I think.
I have NoScript, McAfee SIte Advisor, AdBlock Plus and the Web Developer Toolbar, and between them it keeps my browsing pretty darn safe. 