2026-09-05
每日一文 · 长文精读

Twenty Years of jQuery: How a Little Library Rewired Web Development

jQuery二十年:一个小库如何重塑Web开发

作者:Daniel Curtis · InfoQ 原文

摘要:jQuery于2006年发布1.0版本,以简洁的语法和跨浏览器兼容性降低了Web开发门槛,使JavaScript变得有趣且易用。它通过强大的社区和插件生态影响了后续所有框架。随着浏览器原生API和现代框架的兴起,jQuery逐渐被视为遗留代码,但至今仍被约66%的网站使用。文章回顾了jQuery的历史贡献、社区影响以及当前的地位。

Twenty years ago last week, on 26 August 2006, jQuery 1.0 shipped its first stable release.
二十年前的上周,即2006年8月26日,jQuery 1.0发布了其首个稳定版本。
John Resig had first shown the library at BarCampNYC in January of that year, with a motto that now reads like a mission statement for a generation: writing JavaScript should be fun.
那年1月,John Resig在BarCampNYC首次展示了这个库,其座右铭如今读起来像一代人的使命宣言:编写JavaScript应该是有趣的。
Marking the moment on X this week, Resig wrote: Many of those responsible are quite possibly no longer on this platform, but 20yrs ago TODAY the mythical @jquery launched v1.0.
本周,Resig在X上纪念这一时刻,写道:许多相关人士可能已不在这个平台上,但20年前的今天,传奇的@jquery发布了v1.0。
The jQuery Reunion site, promoting the 20th birthday gathering held in Dallas in January, put it well: Remember the web before the dollar sign?
jQuery Reunion网站宣传了1月在达拉斯举行的20周年聚会,它说得很好:还记得美元符号之前的网络吗?
A time of document.getElementById, wrestling with browser inconsistencies (hello, IE6!), and writing verbose JavaScript just to make a simple dropdown menu work.
那时要用document.getElementById,与浏览器的不一致性作斗争(你好,IE6!),并且为了一个简单的下拉菜单而编写冗长的JavaScript。
jQuery collapsed all of that into $().
jQuery将这一切简化为$()。
You could select elements with CSS syntax, chain operations, animate, and fire off an Ajax request in a line or two, and it behaved the same in every browser that mattered.
你可以使用CSS语法选择元素,链式操作,动画,以及用一两行代码发起Ajax请求,并且在所有主流浏览器中表现一致。
jQuery democratised front-end work.
jQuery使前端工作民主化。
It made JavaScript approachable for designers and back-end developers who found the raw language intimidating, and as one retrospective put it, "the idea that you could write less, do more influenced every framework that came after."
它让那些觉得原始语言令人生畏的设计师和后端开发者也能轻松使用JavaScript,正如一篇回顾文章所说,“写得更少,做得更多的理念影响了之后出现的每一个框架。”
TechCrunch noted as early as 2009 that libraries like jQuery "drastically lower the barrier of entry for developers to build rich web applications."
早在2009年,TechCrunch就指出,像jQuery这样的库“大幅降低了开发人员构建丰富Web应用程序的门槛。”
Going back ten years ago in its ten-year post, the team credited "a strong community of users and contributors who pitched in to help newcomers."
在十周年的帖子中,团队回顾过去,归功于“一个由用户和贡献者组成的强大社区,他们积极帮助新人。”
That community left a bunch of gratitude in the comments, on the 10th anniversary one commenter simply wrote "jQuery saved JavaScript!" while another called it "the life blood of any developer."
这个社区在评论中留下了许多感激之词,在十周年之际,一位评论者简单地写道“jQuery拯救了JavaScript!”,另一位则称其为“任何开发者的生命线”。
On Hacker News that same week, a reader commented: jQuery was important not just because of the feature set, but because it completely dominated the industry.
同一周在Hacker News上,一位读者评论道:jQuery之所以重要,不仅因为其功能集,还因为它完全主导了行业。
jQuery and its ecosystem of plugins created a single community for JS developers.
jQuery及其插件生态系统为JS开发者创造了一个统一的社区。
A lot of subsequent work wouldn't have been as successful without that strong community in place to spread ideas.
如果没有那个强大的社区来传播思想,很多后续工作不会如此成功。
As browsers standardised and frameworks arrived, jQuery became shorthand for a style of code people wanted to leave behind.
随着浏览器的标准化和框架的出现,jQuery成为人们想要抛弃的代码风格的代名词。
The freeCodeCamp forums captured the shift in feeling towards jQuery as frameworks started to take over: I wouldnt say most are disparaging jQuery as they are promoting higher-level alternatives to it.
随着框架开始占据主导,freeCodeCamp论坛捕捉到了对jQuery情感的变化:我不会说大多数人是在贬低jQuery,而是在推广更高级的替代品。
jQuery is all about directly manipulating the DOM in a very procedural way: update this data, find this element, give it this class, put these elements in it, find that element, remove these classes, and so on.
jQuery完全是以非常程序化的方式直接操作DOM:更新这个数据,找到这个元素,给它这个类,把这些元素放进去,找到那个元素,移除这些类,等等。
Modern frameworks like React and Angular are far more declarative, saying this data belongs to this part, here's how it looks, now take care of it whenever it changes.
像React和Angular这样的现代框架则更具声明性,表明这个数据属于这个部分,这是它的外观,现在在它变化时处理它。
Along with the frameworks, browsers started to roll out native replacements.
随着框架的发展,浏览器也开始推出原生替代方案。
querySelectorAll, fetch and classList now cover most of what jQuery was reached for, which is why sites like You Might Not Need jQuery exist and why one developer in a jQuery 4.0 discussion on Hacker News argued "there isn't much reason to use jQuery these days other than keeping with the idioms of a legacy system."
querySelectorAll、fetch和classList现在覆盖了jQuery的大部分用途,这就是为什么像“You Might Not Need jQuery”这样的网站存在,也是为什么一位开发者在Hacker News的jQuery 4.0讨论中认为“如今除了保持遗留系统的习惯外,没有太多理由使用jQuery。”
There is a security dimension too.
还有安全方面的考量。
HeroDevs notes that old jQuery vulnerabilities still dominate real codebases precisely because the library is so deeply and quietly embedded.
HeroDevs指出,旧的jQuery漏洞仍然主导着真实的代码库,正是因为该库被如此深入且悄无声息地嵌入。
W3Techs still puts jQuery on roughly 66 percent of all websites and the overwhelming majority of those running any known JavaScript library, carried along by WordPress, Drupal, Bootstrap and Cypress.
W3Techs仍显示jQuery出现在大约66%的网站上,并且在所有使用已知JavaScript库的网站中占绝大多数,这得益于WordPress、Drupal、Bootstrap和Cypress的带动。
Much of that is legacy, but not all of it is grudging.
其中大部分是遗留代码,但并非都是不情愿的。
A steady stream of "why I still use it" pieces, from Docker's engineering blog to Alex MacArthur's Let's Stop Making it Cool to Hate jQuery, argues the library "helped make the web, and you, what they are today."
从Docker的工程博客到Alex MacArthur的《让我们停止讨厌jQuery》,源源不断的“为什么我仍在使用它”的文章认为,这个库“帮助塑造了网络和你今天的模样。”
jQuery is a fast, small and feature-rich JavaScript library, originally created by John Resig and first released in 2006.
jQuery是一个快速、小巧且功能丰富的JavaScript库,最初由John Resig创建,于2006年首次发布。
It simplifies tasks such as HTML document traversal and manipulation, event handling, animation and Ajax through an easy-to-use API that works across a multitude of browsers.
它通过一个易于使用且兼容多种浏览器的API,简化了HTML文档遍历和操作、事件处理、动画和Ajax等任务。
jQuery is free, open-source software distributed under the MIT license, and is now maintained by the OpenJS Foundation and a community of contributors.
jQuery是免费的开源软件,在MIT许可证下分发,目前由OpenJS基金会和贡献者社区维护。

阅读理解

1. What was the primary motto of jQuery as introduced by John Resig?

2. According to the article, why did jQuery become less popular among developers?

3. What percentage of websites still use jQuery according to W3Techs?

温故复习 →每日一句 →