With the resurgence of interest in dynamic HTML comes a proliferation of JavaScript frameworks. Some are specialized, focusing on just one or two of the above tasks. Others attempt to catalog every possible behavior and animation, and serve these all up pre-packaged. To maintain the wide range of features outlined above while remaining relatively compact, jQuery employs several strategies:

随着对动态html内容的兴趣的复苏,已经产生了很多js框架,一些专门化的关注于仅仅一两个的以上的任务。其他企图处理所有可能的行为和动画,服务所有的没有希望的简易包装。为了在相对简单的同时实现上面提到的很大范围的特点,jquery使用了以下几个策略:

Leverage knowledge of CSS: By basing the mechanism for locating page elements on CSS selectors, jQuery inherits a terse, yet legible, way of expressing a document's structure. The jQuery library becomes an entry point for designers who want to add behaviors to their pages because a prerequisite for doing professional web development is to have knowledge of CSS syntax.

使用css的知识:通过使用css选择器查找元素的机制,jquery继承了一个简洁的清晰的表达文件结构的方法。jquery成为了想为自己的网页添加行为的设计师开始的点,因为做专业的wen开发的先决条件就是有css语法知识。
Support extensions: In order to avoid feature creep, jQuery relegates specialcase uses to plugins. The method for creating new plugins is simple and well-documented, which has spurred the development of a wide variety of inventive and useful modules. Most of the features in the basic jQuery download are internally realized through the plugin architecture, and can be removed if desired, yielding an even smaller library.

支持扩展:为了避免功能变更,jquery把特殊场景下使用的功能交由插件实现。创建新插件的功能很简单而且文档写的很好,这鼓舞了很多中的有用的模块的发展。大部分的下载下来的基础jquery中的大部分特点在内部通过插件机制实现,如果需要的话,可以被移除,生成一个甚至更小的js库。
 Abstract away browser quirks: An unfortunate reality of web development is that each browser has its own set of deviations from published standards. A significant portion of any web application can be relegated to handle features differently on each platform. While the ever-evolving browser landscape makes a perfectly browser-neutral code base impossible for some advanced features, jQuery adds an abstraction layerthat normalizes the common tasks, reducing the size of code while tremendously simplifying it.

解决浏览器兼容性问题:对web开发来说,有一个不幸的事实——每一个浏览器都有自己一系列的与发布的标准的偏差,对任何一个web应用来说,一个重要的部分就是处理每一个平台的不同。然而多种浏览器平台胆汁创造完美的浏览器兼容的待吧对某些高级的功能来说使几乎不可能的。jquery添加了一个抽象层,使这些平常的任务变的正常,在简化的同时缩短了代码的大小。

Always work with sets: When we instruct jQuery, "Find all elements with the class collapsibleand hide them," there is no need to loop through each returned element. Instead, methods such as .hide()are designed to automatically work on sets of objects instead of individual ones. This technique, called implicit iteration, means that many looping constructs become unnecessary, shortening code considerably.

同时处理一系列元素:当我们命令jquery:"找到所有带有collapsible的类,并隐藏他们",我们不需要通过每一个返回的值循环操作。相反,.hide()这样的方法被设计的就是自动和一系列的对象一起工作。而不是和分离的。这种技术被称之为隐式迭代,意味着很多循环可以不是必须的,优雅的减少了代码。

Allow multiple actions in one line: To avoid overuse of temporary variables or wasteful repetition, jQuery employs a programming pattern called chainingfor the majority of its methods. This means that the result of most operations on an object is the object itself, ready for the next action to be applied to it.

允许在一行代码中操纵多个动作:为了避免滥用临时变量和浪费的重复,jquery使用了被称之为chaining的编程模式作为他的方法的主体。这意味着对一个对象的大部分操作的返回值是这个对象自己,准备好了让下一个操作去使用。

These strategies have kept the jQuery package slim—roughly 30 KB, compressed—while at the same time providing techniques to keep our custom code that uses the library compact.

这些策略让jquery变的很轻,压缩后大约只有30kb,同时提供技术让我们让使用了jquery的普通的代码变的简洁。
The elegance of the library comes about partly by design, and partly due to the evolutionary process spurred by the vibrant community that has sprung up around the project. Users of jQuery gather to discuss not only the development of plugins, but also enhancements to the core library. The users and developers also assist in continually improving the official project documentation,which can be found at http://api.jquery.com.

jquery代码的优雅部分源于设计,部分源于受围绕jquery如雨后春笋般建立的充满生机的社区的鼓舞而发生的进化。jquery的用户聚集在一起不仅仅讨论开发插件,同时讨论增强核心库的功能。用户和开发者也帮助持续提高官方项目的文档,你可以在 http://api.jquery.com上找到这些文档。
Despite all of the efforts required to engineer such a flexible and robust system, the end product is free for all to use. This open source project is dually licensed under the MIT License(to permit free use of jQuery on any site and facilitate its use within proprietary software) and the GNU Public License(appropriate for inclusion in other GNU-licensed open-source projects).

尽管付出了很大的努力去开发这样灵活而且健壮的系统,最终的产品依然是对所有人免费的。这个开源项目在MIT许可(允许在任何站点上免费使用jquery,同时在正确的软件上正确的促进他的使用)和GNU公共许可(包含其他GNU许可的开源项目是可以的)的双重许下。

(2)入门指南——(3)为什么jquery工作的很好(Why jQuery works well)的更多相关文章

  1. web前端基础知识及快速入门指南

    web前端基础知识及快速入门指南 做前端开发有几个月了,虽然说是几个月,但是中间断断续续的上课.考试以及其它杂七杂八的事情,到现在居然一直感觉自己虽然很多前端的知识很眼熟,却也感觉自己貌似也知识在门口 ...

  2. RequireJS 入门指南

    RequireJS 入门指南 http://requirejs.org/ 简介如今最常用的JavaScript库之一是RequireJS.最近我参与的每个项目,都用到了RequireJS,或者是我向它 ...

  3. Ext JS 6学习文档–第1章–ExtJS入门指南

    Ext JS 入门指南 前言 本来我是打算自己写一个系列的 ExtJS 6 学习笔记的,因为 ExtJS 6 目前的中文学习资料还很少.google 搜索资料时找到了一本国外牛人写的关于 ExtJS ...

  4. Day 19: EmberJS 入门指南

    编者注:我们发现了有趣的系列文章<30天学习30种新技术>,正在翻译,一天一篇更新,年终礼包.下面是第19天的内容. 到目前为止,我们这一系列文章涉及了Bower.AngularJS.Gr ...

  5. 【翻译】Fluent NHibernate介绍和入门指南

    英文原文地址:https://github.com/jagregory/fluent-nhibernate/wiki/Getting-started 翻译原文地址:http://www.cnblogs ...

  6. 一小时包教会 —— webpack 入门指南

    什么是 webpack? webpack是近期最火的一款模块加载器兼打包工具,它能把各种资源,例如JS(含JSX).coffee.样式(含less/sass).图片等都作为模块来使用和处理. 我们可以 ...

  7. ASP.NET MVC 5 入门指南汇总

    经过前一段时间的翻译和编辑,我们陆续发出12篇ASP.NET MVC 5的入门文章.其中大部分翻译自ASP.NET MVC 5 官方教程,由于本系列文章言简意赅,篇幅适中,从一个web网站示例开始讲解 ...

  8. 一起学微软Power BI系列-官方文档-入门指南(1)Power BI初步介绍

    我们在前一篇文章微软新神器-Power BI,一个简单易用,还用得起的BI产品中,我们初步介绍了Power BI的基本知识.由于Power BI是去年开始微软新发布的一个产品,虽然已经可以企业级应用, ...

  9. 一起学微软Power BI系列-官方文档-入门指南(5)探索数据奥秘

    我们几篇系列文章中,我们介绍了官方入门文档与获取数据等基本知识.今天继续给大家另外一个重点,探索数据奥秘.有了数据源,有了模型,下一步就是如何解析数据了.解析数据的过程需要很多综合技能,不仅仅是需要掌 ...

随机推荐

  1. Qt Label show Images

    第一.我们需要让QLabel的大小不因为图片的大小变化而变化,可以用下面语句实现 ui->imageLabel->setSizePolicy(QSizePolicy::Ignored, Q ...

  2. 使用堆栈结构进行字符串表达式("7*2-5*3-3+6/3")的计算

    问题: 给定字符串String str = "7*2-5*3-3+6/3", 求出字符串里面表达式的结果? 像javascript有自带的eval()方法,可以直接计算.但java ...

  3. Solr-4.10.2与Tomcat整合

    1.将下载的solr解压至D:\solr,拷贝d:\solr\solr-4.10.2\example\webapps\solr.war到Tomcat的webapps\目录中.直接解压 solr.war ...

  4. 线段树练习 codevs 1080

    /* codevs 1080 线段树练习 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 钻石 Diamond 题解 查看运行结果 题目描述 Description 一行N个方格,开 ...

  5. Mysql学习(慕课学习笔记4)创建数据表、查看数据表、插入记录

    创建数据表 Create table [if not exists] table_name(column_name data_type,…….) UNSIGNED 无符号SIGNED 有符号 查看创建 ...

  6. html5 百分比计算

    这几天一直在看html5,看到了百分比的计算公式:目标元素的尺寸/上下文元素的尺寸=百分比尺寸.看到这个公式,有点懂,但是有不明白.对于目标元素很容易理解,但是对于上下文元素就不是很好理解了.试了一些 ...

  7. 分数(有理数)的四则运算PAT1088

    2015-02-05 PAT- B1088. Rational Arithmetic (20) http://www.patest.cn/contests/pat-a-practise/1088 #i ...

  8. Jasper_crosstab_columngroup header position config - (headerPosition="Stretch")

    Position of Totals RowThe totalPosition attribute controls the appearance of the row that displays t ...

  9. DAO 基础学习笔记

    一.DAO 1.概念: (1)Date Access Object(数据存取对象) (2)位于业务逻辑和持久化数据之间 (3)实现对持久化数据的访问 (4)类---> DAO --->数据 ...

  10. http、TCP/IP协议与socket之间的区别

    http.TCP/IP协议与socket之间的区别     网络由下往上分为:  www.2cto.com   物理层--                       数据链路层-- 网络层--   ...