views:

62

answers:

2

What are best practices and tips to use JavaScript without losing the site's Accessibility, usability and SEO, and site's content if JavaScript is disabled but still keeping site usability for JavaScript enabled users?

In what scenarios we should avoid full dependency on JavaScript?

+2  A: 

You should be developing the website using the principles of progressive enhancement.

That is, make it work (and look OK) without CSS and Javascript. Add CSS, then Javascript progressively. The idea is that you can use CSS and Javascript to change the original markup and make it work in a better way, but the site will still work well if they are not present. It is the flip side of graceful degradation.

That takes care of accessibility, in terms of general javascript use, and also works well for SEO as your website content will be available to the different bots, whether they use javascript or not.

Oded
Are these Javascript uses ok to use 1. http://stackoverflow.com/questions/2355537/how-to-add-target-blank-to-all-pdf-links-inside-div-using-jquery 2. http://stackoverflow.com/questions/1899913/how-to-detect-linked-pdf-on-a-page-and-show-message-to-download-adobe-reader-usin 3. http://stackoverflow.com/questions/2019532/how-to-show-back-to-top-button-using-jquery-only-if-browser-height-is-shorter-t
metal-gear-solid
@metal-gear-solid - with each of these, ask yourself, will the site _work_ OK without this javascript? If not, then they are _not_ OK.
Oded
@Oded - As i think in all those situations all are not a actual part of site content. content will be still accessible. am i right?
metal-gear-solid
@metal-gear-solid - They do impact usability, so long as you can _keep_ the same kind of use without the javascript, you are ok.
Oded
Yes they do impact usability but it will be only problem for JavaScript disabled user which are very low. and none of those are critical content and functionality. those are additional. so can i say this condition as "progressive enhancement."?
metal-gear-solid
@metal-gear-solid - "progressive enhancement" is about both content and usability, so if there is an impact on usability (that is, a javascript disabled user can't use a feature of the site at all), then you can't call it that. If the javascript just makes things easier for other users, then it's fine.
Oded
@Oded - yes in all cases the use of JavaScript is just making things easier for JavaScript enabled users. all content is still accessible even if js is disabled.
metal-gear-solid
A: 

If You use MVC, you can easy build 2 controllers for every page, one which produces rich client side application with javascript, etc.; 2nd which produces simple interface only with links and text.

codez