开发者

Is it still bad practice to build a website that relies on javascript?

Is it still bad practice to create a website that relies on javascript?

I know it used to be, but nowadays most browsers support them... Why or why not should I wo开发者_如何学Pythonrry about this?


Spending extra effort to make a site work without Javascript is becoming increasingly ridiculous when so much of the web breaks when you disable it.

For example, did you know that you can't install Google Chrome when you're using a browser without Javascript? Their "accept and install" button requires Javascript.

Is it still bad practice to build a website that relies on javascript?

You should, of course, use the <noscript> tag to display appropriate messages to the user that may have accidentally disabled Javascript in their browser. Google places this text at the top of their page via the noscript tag:

You need a JavaScript-capable browser to download this software. Click here for instructions on how to enable JavaScript in your browser.

I admit this was a surprising case when I discovered it, because well... it's Google. And millions of people have downloaded Chrome. But I think it illustrates the point that a site dependent on Javascript is a pretty normal thing today.


Depends on the target audience, but more importantly how you're using JavaScript.

Using it for effects that don't interfere with any actual functionality is usually fine.

If you want to target a broad audience and your website is non-functional without JavaScript, then you may want to reconsider.


No modern, interesting, web application does not use JavaScript. A content-only site might not use it, and any web site should warn the user that JavaScript is required, but it's been a long time since "no JavaScript" made any sense.


Search engines still do not evaluate JavaScript. If you want your site to be indexed, all the content needs to be accessible without JavaScript.


It's not bad practice to rely on JavaScript, but I would say it's bad practice to assume without checking that JavaScript is enabled.

At the very least your website should give the user a nice error if JavaScript is disabled. Ideally, at least the basic functionality (such as text content and images) should still work and JavaScript should enhance it: see Unobtrusive JavaScript.


You should know your target audience of course. If you know that everybody will be using a certain browser for something like an intranet application then you can probably assume that they will be using JavaScript.

If you are writing an application for the general public, then I would take extra effort to write it such that it works without JavaScript. Then use JavaScript to enhance the existing solution. It takes extra effort, but you can make an application both accessible and interesting if you try.

EDIT: Also thought I would add since I haven't seen any references to it, but building a website that relies on straight JavaScript (and not a common JavaScript library like JQuery) would be unwise. JQuery helps you address some of the browser differences that made JavaScript so problematic a few years back (not to mention doing more with less code).


The new HTML5 standard, which many browsers are already starting to support, relies pretty heavily on scripting for much of its new APIs. So no, it is not bad practice to use scripting, it is encouraged.


If you're making a website that's available on the internet and whose audience is more than just people you know, then it's absolutely not OK to build it so that it doesn't work without JavaScript. Many people and corporations choose to browse the web with JavaScript turned off, for many reasons, and you need to remember that the majority of users are not developers and do not browse the web in the same way with the same tools as you.

Use progressive enhancement: start by creating and testing all the core functions of your site with simple HTML. When that works, add JavaScript functionality.

Developing a highly interactive web application is a different matter. For that, it's not unreasonable to insist on your users using particular browsers with JavaScript enabled.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜