Is graceful degradation in the absence of JavaScript still useful?

别说谁变了你拦得住时间么 提交于 2019-12-05 18:19:27

问题


When even mobile browsers have JavaScript, is it really necessary to consider potential script-free users?


回答1:


Yes. Your web pages aren't just consumed by people: they're consumed by search engines, and crawlers, and screenscrapers. Most of those automatic tools don't support Javascript, and essentially none are going to generate UI events or look at deeply nested AJAX data. You want to have a simple static HTML fallback, if nothing else then so that your web pages are well indexed by the search engines.

Forget the crazies who disable Javascript; think of the robots!




回答2:


Yes.

People can (and do) browse with javascript disabled. If your site will work without users having to explicitly enable javascript for you, that makes them happy.

Exactly how relevant depends on your target audience, of course.




回答3:


I would argue that you shouldn't go significantly out of your way to accommodate for non-JS users for the following reasons:

  • All Modern Browsers Support JS

    This is a snapshot of browser usage today:

    http://www.w3schools.com/browsers/browsers_stats.asp

    Even the oldest common browser, IE6, supports basic JavaScript and AJAX. If you decide not to integrate certain features b/c of a JS dependence, this proves that you are essentially doing it for people who started with JavaScript enabled and explicitly chose to disable it. I think these people should expect for some features, and perhaps even entire sites, not to work as a consequence.

  • Few People Willingly Disable JS

    Building on my point above, average web users don't know or don't care that JS can be disabled in browsers. It's largely a tech savvy crowd who knows how to do this (myself included), and as tech savvy users we should know when to turn it back on as well.

  • Cost of Support

    In light of the above, consider that choosing to accomodate users who have primarily willingly disabled JS comes with a very real cost. If you are managing a large project with heavy UI requirements, you can easily burn a lot of developer hours accommodating for what is a very small user preference. Check your budget. If it is going to take 2 devs working 40 extra hours each on the project to accomplish this feat, you are easily going to burn a few thousand dollars on what is essentially a non-issue for the vast majority of your users. How about using that time and investment to further buff up your core competency?

  • Precedence

    I may very well be wrong on this, but I think it would be difficult to find major media or social sites that
    don't rely on JavaScript for some
    portion of their functionality to
    work. If major businesses that rely
    on the operation and accessibility of their site to stay in business aren't doing it, there's a good chance it's because it isn't needed.

CAVEATS:

Know your market. Continue to build XHTML/CSS that is semantic (preferably by using the RDFa W3C recommendation). Still strive to make your sites accessible to the visually impaired. Don't believe everything you read. ;)

DISCLAIMER:

My argument above is largely dependent on how you define "graceful degradation." If you mean all the links still work, that's one thing, but if you mean all the links still work and so does the wombats game, that's another. I'm not trying to argue for making your site so JS dependent that non-JS users can't access any portion of it. I am trying to make an argument for the acceptability of certain features, even some core features, being reliant on JS.




回答4:


It is relevant and it will be relevant even after 10-20 years when javascript might be supported everywhere. making things work without javascript is important development technique because it forces you to keep things simple and declarative. ideally javascript should be used only to enhance experience but your website shouldn't depend on it.

there is clear advantage from maintenance point of view to have most of the code in declarative format (html+css) and as little as possible in imperative (javascript).




回答5:


My position:

I browse with NoScript, so if I come on your site it will be without benefit of Javascript. I don't expect the full user experience.

What I want, before turning on JS, is to be assured that you're reasonably competent and not malicious, and that I actually want what you're using JS for.

This means that, if you actually want me to use your site, you should allow me to look around, using links. (If I see a site that's totally useless without Javascript, I generally think the designers were incompetent.) You should let me know what sort of functionality I'll get from enabling Javascript, and you should present the site in a legitimate-seeming way.

I don't think that's too much to ask.




回答6:


graceful degadation / progressive enhancement / unobstusive javascript is absolutely relevant!

as with all accessability issues: just imagine for one second what it's like to be the one on the outside who can't use the page.

imagine you're travelling around the world, you're in some hotel or internet café with really old computers, old software, old browsers, you want to look up your flight and you realize you can't because of some javascript incompatability in the old browser you're using. (try 'old mobile phone' or 'stuck behind a corporate firewall' for different scenarios)

image what a world of possibilities opend up to blind people with screen readers and the web, and image what it's like to find these possibilties closed again because of javascript.

so much for appealing to your better nature.

you might also want to do it to keep your site accessibly for search engines.




回答7:


Yes, it's relevant. Mobile browsers in use today do not all have Javascript enabled. It's available on new phones, sure. But there are millions and millions of people like me, who have phones running older browsers, and for all of us, a JS-required browsing experience is just plain broken.

I don't even bother visiting sites that didn't have progressive enhancement in mind when they coded. I'm not technically behind the times. My phone is a year old. But I'm not going to re-up my contract and buy a new phone because of a crippled web experience.




回答8:


It depends on who your target audience is. I have JavaScript turned off by default and turn it on when I know what the site's intent is.




回答9:


It's generally much faster to browse with Javascript disabled (digg.com is lightning without JS), which is why it's popular.

In Opera it's really easy: you simply press F12 and untick the javascript option. I always browse without Flash, Java (not javascript), animated images and sound. I enable Flash on a per-site basis, eg YouTube. Sometimes I turn off JS temporarily if my system is slowing down.

And don't forget about:

  • Screen readers (I think they mostly have JS disabled)
  • Text browsers or other very old systems
  • Ad blockers (if your filename happens lands under their radar)
  • Any old browser that either doesn't support JS at all or the JS breaks (e.g. IE6 doesn't support some modern JS stuff).

The solution is to use progressive enhancement rather than graceful degradation, i.e. start with the basic HTML and add CSS. Then add Javascript and/or AJAX to parts of the site.

For example, if you had a site like Stack Overflow, voting up an answer could submit a form normally. If JS is enabled, it would do an AJAX request, update the vote count and cancel the form submission, without leaving the page. SO doesn't do this though...




回答10:


I for one always have NoScript turned on unless I trust the site for a number of reasons including cross-site-scripting, click jacking, and HTML injection. It's not me being paranoid, it's because I know a lot of developers, and know most of them have no idea what web security is, never mind how to avoid vulnerabilities.

So until I trust a site there's no chance I'd let it do anything fancy.

For the unfamiliar, there are some interesting blog entries on the subject:

  • Protecting Your Cookies: HttpOnly
  • Cross-Site Request Forgeries and You
  • Sins of Software Security
  • Top 25 Most Dangerous Programming Mistakes



回答11:


I'm going to have to make a case for the other side here. Peoples reasons for designing sites without javascript are largely idealistic. Given an enough time and money and the goal is achievable and will certainly open your website to the largest possible number of people. However in reality doing this will slow your development, increase the number of test cases that you have to deal with, and ultimately affect the quality of your application for those users that do use javascript.

In my opinion it is perfectly reasonable to choose to make your site only compatible with js enabled browsers and tell those users that dont have it that they are missing out. This allows you to concentrate on creating rich content that the majority of users will be able to view.

There are of course exceptions to this rule, but if you are looking to create a good website for the majority of users, or have a client who is after a flashy website with limited time or money then taking the decision that it is js enabled browsers only is a reasonable thing to do.




回答12:


The real question is not whether it is relevant, but whether to use Graceful Degradation, or Progressive Enhancement as your scripting strategy.




回答13:


I'm actually in an interesting position when it comes to graceful degradation of JS. I'm working on a web application that bots and crawlers have absolutely no business looking into. There's nothing they can gleam that should be indexed.

The informational site accompanying the web application, however, should be indexed, and therefore JS degrades gracefully there.

In the web application, if you don't have JavaScript enabled, you're probably not supposed to be there. It's intended to be a rich interactive experience. The web application actually requires JS to be enabled, and for you not to be sitting behind a corporate firewall.

We're not serving anything malicious, its just our intent and purpose for the web application that's different. The goals of our web application and those of our informational site are completely different.




回答14:


I use JavaScript. I always keep my browser up-to-date. But sometimes, my Internet connection is so bad that scripts just don't load.

There are also cases when:

  • Some scripts load, but others fail, in which case parts of a website stop functioning
  • Scripts are loading, but I want to hit "submit" without waiting for that fancy frilly menu
  • A script malfunctions because it was partially loaded and then cached at that half-stage
  • I'm in such a hurry that I just decide to use Lynx.

Now, I'm not saying my Internet is bad all the time, or even most of the time, but it does happen. With the Internet expanding rapidly to many rural areas across the world, I'm sure I'm not the only one. So apart from bots as Nelson mentioned above, it's another thing to keep in mind. (Hint: check your demographics).




回答15:


If you don't want the page to work when Javascript is off then just have that be the message in html, and if javascript is on, by using unobtrusive javascript you can get rid of that message and make visible the rest of the application.

Depending on what you write for, in terms of javascript version, you may need to degrade if the browser the user has doesn't not have the latest version, so gracefully handling that is also important.



来源:https://stackoverflow.com/questions/1267175/is-graceful-degradation-in-the-absence-of-javascript-still-useful

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!