禁用 JS 的浏览器
几年前,我在设计时常常考虑到禁用 JavaScript 的浏览器。如今它有多重要?
这真的是你需要担心的事情吗?我在现实生活中从未遇到过禁用 JavaScript 的用户。有人有数字吗?
Years ago I used to design with JavaScript disabled browsers in mind. How important is it nowadays?
Is it really something you need to worry about? I've never come across a user in real life who has JavaScript disabled. Anyone got any figures?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
以下是一些一般准则。使用不同浏览器并考虑可访问性的人,或者在没有图形工具包(基于文本)的终端中运行的人最有可能不运行JavaScript。如果你想迎合这些人,你所需要做的就是使用 JavaScript(如果你愿意的话),但只是用它来增强,而不是提供内容。
我的意思是,例如,您可以通过使用 JavaScript 添加排序控件来增强表格,但不要使用 JavaScript 来解析数据文件并创建表格。使用服务器端程序来处理数据库或数据文件。
然而,这就出现了一个灰色地带,而这一切都与你的目标用户群类型有关。如果您正在编写 Chrome 实验,那么请务必用 JavaScript 编写;这是关于 JavaScript 的。
但是,如果您的网站旨在提供信息,则最好尽可能避免使用 JavaScript提供内容;只是增强它。
Here's a couple of general guidelines. People who use different browsers with accessibility in mind, or run in a terminal with no graphics toolkit (text based) are most likely to not run JavaScript. If you want to cater to these people, all you need to do is use JavaScript if you want, but only use it to enhance, not provide the content.
By this, I mean, for example, you can enhance a table by adding sort controls with JavaScript, but don't use JavaScript to parse a data file and create the table. Use a server-side program to handle a database or data file instead.
However, there becomes a grey area, and this all has to do with what kind of user base you are targeting. If you are writing a Chrome experiment then by all means, write it all in JavaScript; it's about the JavaScript.
If, however, your website aims to provide information, it's best to avoid using JavaScript to provide content wherever possible; only enhance it.
我参加聚会有点晚了,但在提出这个问题大约一个月后,雅虎!已发布实际统计数据。
简而言之,这取决于您的访问者来自哪里,但在美国,您可以计划让大约 2% 的访问者禁用 JavaScript。
I'm a bit late to the party, but about a month after this question was asked, Yahoo! published actual stats.
In short, it depends on where your visitors are from, but in the US, you can plan on about 2% of your visitors having javascript disabled.
我同意禁用 javascript 并不常见,而且我也同意在构建网站时考虑禁用 javascript 的浏览器很重要。
但是 javascript 在现代和现代社会中受到了强烈的喜爱。现在的大型网站(谷歌、youtube、facebook)。如果没有 javascript,您就无法构建支持 AJAX 的网站,也无法使用 jQuery 或任何 js 库的强大功能。
如果您担心跨浏览器合规性,您可能需要考虑使用 jQuery,因为它抽象了著名的跨浏览器问题。
就我个人而言,我将始终在我构建的任何网站中使用 javascript :)。
I agree that disabling javascript is uncommon and i also agree that it's important to build websites while taking javascript-disabled browsers in mind.
BUT javascript is strongly invloved in modern & large websites now (google, youtube, facebook). without javascript you can't build AJAX supported websites and you can't also use the power of jQuery or any js library.
and if you are worry about cross browser compliance, you might wanna consider using jQuery because it abstracts away the famous cross-browser issue.
personally, i'll be always using javascript in any website i build :).
Firefox 的
NoScript
插件已被下载 73,063,406 次。您的网站应该可以在没有 JS 的情况下使用(因此,除非绝对必要,否则不要用 JS 巫毒替换链接)。
另外,需要特殊输出设备(例如盲文阅读器)的人会更喜欢无需 JS 即可工作的网站。
The
NoScript
plugin for Firefox has been downloaded 73,063,406 times.Your site should be usable without JS (so don't replace links with JS voodoo unless you absolutely have to).
Also people that need special output devices (like Braille Readers) will prefer sites that that work without JS.
你是对的:直接禁用 Javascript 现在已经很少见了,因为很多网站都使用它。
然而,大多数浏览器都有更精细的控制;即按站点打开/关闭它,这可能仍然被偏执的..呃,有安全意识的用户使用。
更有可能的是,有一个名为 NoScript 的 Firefox 扩展实际上非常流行。此扩展使用户可以更好地控制何时允许 Javascript。我不知道其他浏览器是否有类似的插件,但我希望有。
最后,许多残疾用户将运行屏幕阅读器或其他辅助浏览器,这些浏览器可能仍然无法正确/根本运行 Javascript。如果您想支持这些用户,那么您需要了解他们工作的独特环境。
所以,是的,支持非 JS 用户仍然是一个好主意,即使他们只是少数。也就是说,我不认为你需要让一切都为他们工作,只要你的基本网站功能正常工作(即添加到购物篮、结账等),就没有必要因为他们没有收到通知而感到太大压力口哨声。
You're right: straight up disabling of Javascript is pretty uncommon these days because it is used by so many sites.
However most browsers have more fine-tuned control; ie to turn it on/off per site, which may still be used by paranoid.. uh, security-conscious users.
Even more likely, there's a Firefox extension called NoScript which is actually very popular. This extension gives the user even more control over when to allow Javascript. I don't know whether there's similar plug-ins for other browsers, but I expect so.
Finally, many disabled users will be running screen-readers or other accessibility browsers which may still not run Javascript properly/at all. If you want to support these users, then you'll need to be aware of the unique environments they work in.
So yes, it is still a good idea to support non-JS users, even if they are in the minority. That said, I don't think you need to make everything work for them, as long as your basic site functionality works (ie add to basket, checkout, etc), there's no need to get too stressed about them not getting the bells and whistles.
我的建议是:
设计一个不使用 JS 的网站通常是完全可能的,而且并不是那么困难。无论有关禁用 JS 的浏览器的统计数据如何,您都应该考虑这样做。
但是,不要让这阻止您发挥创造力。如果您必须依赖 JS 并且没有解决方法,请不要犹豫。如果有人想要完整的浏览体验并在关闭 JS 的情况下工作,那是他/她的错。
使用 JS unescape() 对电子邮件进行编码始终是一个好主意。在禁用 JS 的浏览器中,不显示任何内容。
My tips would be:
Designing a site with a fallback to no JS is usually entirely possible and not all that difficult. You should consider doing it, regardless of what the statistics about JS-disabled browsers say.
However, don't let this stop you from being creative. If you must rely on JS and there's no workaround, don't hesitate. If someone wants full browsing experience and works with JS off, it's his/her fault.
Encoding emails using JS unescape() is always a good idea. In a JS-disabled browser, just display nothing.
我自己的公司工作了一年,又在另一家公司工作了几年,我的直接客户都没有禁用过 JavaScript,在一个例子中,我的一个客户禁用了 JavaScript,所以我目前的猜测(纯属轶事证据)约为 1/50.000。
在使用 JavaScript 时,我最大的担忧始终是跨浏览器合规性,在 FF 中有效的内容并不总是在 Chrome 中有效,在 FF 和 Chrome 中有效的内容并不总是在 IE 8 中有效,以及在所有浏览器中都有效的内容。上面...并不总是在 IE 7 中工作...
然后是 IE 6。
编辑,数据:
截至 2009 年 7 月 31 日,Firefox 拥有 10 亿 下载
Noscript 截至 2010 年 9 月 14 日7300万次下载
这告诉我们,大约7%的FF用户在下载该浏览器时,也安装了noscript插件。
编辑附录
创建这个社区 wiki,添加您的数学人员。
编辑:
2010 年 10 月,Yahoo!已发布实际统计数据。
简而言之,答案因国家/地区而异,但对于美国网站,您可以预期 2% 的用户禁用了 javascript。
Having had my own company for a year and working at another for a couple of years, none of my direct clients has ever had JavaScript disabled, in one single instance I've had one of my clients customers have JavaScript disabled, so my current guess (purely anecdotal evidence) is about 1/50.000.
My biggest worry when working with JavaScript is and has always been cross browser compliance, what works in FF doesn't always work in Chrome, what works in FF and Chrome doesn't always work in IE 8, and what works in all of the above... doesn't always work in IE 7.....
And then there is IE 6.
Edit, yay data:
By July 31, 2009 firefox had 1 billion downloads
Noscript has as of September 14, 2010 73 million downloads
That tells us that about 7% of the times FF users has downloaded the browser, they have also installed the noscript plugin.
Edit addendum
Making this community wiki, add your math people.
Edit:
In October 2010, Yahoo! published actual stats.
In short, the answer varies by country, but for a US site, you can expect 2% of your users to have javascript disabled.