编程与软件工程kryogenix.org
每个人都有 JavaScript,对吧?
Everyone has JavaScript, right?
2015 — 2024,它一次次回到首页
黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。
导读
这个经典页面提醒开发者:不能假设所有访问者都成功加载并运行了 JavaScript,并列出脚本被禁用、加载失败、被拦截等常见情形。它由此论证为什么要考虑渐进增强,以及在 JS 不可用时页面仍应尽量可读可用。
为什么经久不衰:它用一份简洁的清单打破了“人人都有 JS”的默认假设,是理解渐进增强与 Web 韧性的经典提醒;在 JS 越来越重、前端依赖越来越复杂的今天仍值得重读。
HN 评论精选
批评 JS 布局导致手机阅读卡顿,强调内容阅读应优先。
我越来越常遇到用 JS 做布局的网站,在手机上体验极其糟糕。整个站点加载完,我读文章读了四五秒,然后 JS 启动,滚动被锁住,页面重绘时一切都停住。在一些网站上——包括 Android Central 这种——这会让我已经能看到的文字被卡住 20 秒以上等待重排。完全不可接受。永远记住:人们来你的网站几乎只是为了看文字。如果你那愚蠢的 JavaScript 干扰了文字的阅读,你作为开发者就失败了。
donatj查看英文原文
I find more and more sites using JS for layout and it being an incredibly frustrating experience on my phone. The whole site loads and I'm reading the article for 4 or 5 seconds and then the js kicks in, scrolling locks, everything stops while The page redraws. On some sites, including Android Centeral of all things, this can stop me from reading text I ALREADY HAVE for upwards of 20 seconds while it reflows. Simply unacceptable. ALWAYS keep in mind that people are coming to your site for the text almost exclusively. If your stupid JavaScript interferes with the consumption of said text you have failed as a developer.
认为请求失败并非 JS 独有,反对把问题只归咎于 JavaScript。
没错,但这些问题是 JavaScript 请求特有的吗?任何请求都可能失败、被拦截、被干扰或只收到一部分。用户也可以关掉 CSS。HTML 页面也可能加载不全。那又怎样?有些问题可以用 HTTPS 或 HTTP/2 解决,有些靠 CDN 回退或合理编码,有些不是开发者的问题——比如糊涂用户装了恶意扩展,或者勒德分子用户关掉 JS。为什么不问“每个人都有 HTML 吧?”
cabirum查看英文原文
Right, but these problems are not specific to javascript requests. Any request can fail, be blocked, interfered with, or partially received. Users can switch off CSS, too. Html page may not load completely. So what? Some of these issues are fixed with https or http/2. Some with CDN fallbacks or just sane coding. Some are not developers problems - such as clueless users installing malicious extensions or luddite users switching off js. Why not ask 'Everyone has html, right?'.
主张内容站用纯 HTML/CSS、应用站用 JS,不喜欢半吊子的渐进增强。
我不完全同意 JavaScript 应该按渐进增强的方式来开发,原因有两个:如果你可以不用它(渐进增强的“渐进”意味着没有 JS 站点仍可用),那我认为你根本不该用 JS。语义化 HTML 和 CSS 在让内容自适应各种用户和设备方面已经非常出色。搜索引擎期望文档以某种方式排布。网页抓取器即使对没有公开数据 API 的站点也能增加大量价值。你很难做得更好,却很容易弄得更糟。另一方面,内容站点不再是 Web 的全部。Web 越来越是应用的部署平台,有很多应用没有 JS 根本不能在浏览器里做。抱怨“但我关了 JS”的勒德分子不是浏览器内图像编辑器的目标市场。那时候加载不了 JS 就是加载应用失败,再多的 Progresso Soup 也没用。所以,我更喜欢全有或全无。
moron4hire查看英文原文
I'm not sure I entirely agree that JavaScript should be developed in a Progressive Enhancement style, for two reasons: If you can live without it (the "progressive" part of progressive enhancement implies that the site is still usable without the JS), then I don't think you should be using JS at all. Semantic HTML and CSS are pretty amazing at adapting content fluidly and dynamically to a wide range of users and devices. Search engines expect documents to be laid out in a certain way. Web scrapers can add a whole pile of usefulness even to sites that don't create explicit public data APIs. You're going to have a serious hell of a time making it any better, and can easily make it a lot worse. And on the other hand, content sites aren't the be-all, end-all of the Web anymore. The Web is increasingly a deployment platform for applications, and there are a whole host of applications that just can't be done in the browser without JS. Luddites who complain about "but I got JS disabled" aren't the target market for an image-editor-in-the-browser. Failing to load JS at that point is just plain failure to load the application and no amount of Progresso Soup is going to help you. So yeah, I much prefer all or nothing.
认为禁用 JS 的用户是少数,不应为照顾他们牺牲开发效率。
首先,也许会让你惊讶……我们知道你存在。是的,戴锡箔帽的你,在压抑的企业制度下的你。你一直想通过愤怒的博客文章、愤怒的评论让我们知道你的存在,以为我们不知道。我们知道,但我们发现你不仅是少数,而且只要忽略你,我们设计师和开发者的生活就会轻松一百万倍。是的,我知道你想用 vim 或 IE6 上网,但那是你的选择。自己铺的床自己躺,但别拖我们下水!
demarq查看英文原文
Firstly and this may suprise you you... We know you exist. Yes you with a tinfoil hat, you under a repressive corporate regime. You keep trying to make your presence known through ranty blog posts, angry comments thinking we dont know you exist. We know but we found that not only are you a minority but our lives as designers and developers are a million times easier if we just ignore you. Yes i know you want to surf with vim or IE6 but thats your choice. You make your bed now lie in it but dont drag the rest of us with you!
历次讨论
同类还值得读
开源应用架构
The Architecture of Open Source Applications
《开源软件架构》(AOSA)是一本在线免费书,邀请知名开源项目的作者亲自剖析其内部设计,涵盖 SQLAlchemy、LLVM、Audacity、Apache、Bash 等系统。
编程与软件工程上首页 9 次 · 2011–2024aosabook.org编辑精选编程语言简史:简短、不完整且多半错误
A Brief, Incomplete, and Mostly Wrong History of Programming Languages
一篇以戏谑、故意不准确的方式回顾编程语言史的博客文章,用夸张轶事和讽刺定义串起 Lisp、C、C++、Java、JavaScript、PHP 等语言。
编程与软件工程上首页 8 次 · 2009–2021james-iry.blogspot.comSQLite 是如何测试的
How SQLite is tested
SQLite 官方文档页,系统介绍 SQLite 的测试体系:多种测试方法(TCL 测试、模糊测试、回归测试、静态分析等)和海量测试用例,展示了这个小型开源项目如何靠极致测试获得…
编程与软件工程上首页 8 次 · 2009–2025sqlite.org编辑精选高级编程语言(2009)
Advanced programming languages (2009)
Matt Might 的经典文章,按用途推荐“高级编程语言”:如果追求就业就选主流语言,如果追求表达力、学术研究或创业,则推荐 Haskell、OCaml、Scala 等函数式语…
编程与软件工程上首页 8 次 · 2009–2022matt.might.net我的 Forth 与栈机器经历
Yosefk - My history with Forth & stack machines
作者以亲身经历回顾了使用 Forth 语言和栈式机器的历程:既赞叹其简洁优雅、代码量小、可自举的优点,也坦率指出栈操作在实际编程中的痛苦,以及 Forth 社区文化中的问题。
编程与软件工程上首页 8 次 · 2010–2024yosefk.com编辑精选