翻译 Secrets of the JavaScript Ninja 边译边学(2)

Secrets of the JavaScript Ninja 边译边学(2)

第一章 进入忍者的世界

原文
In this chapter:

  • A look at the purpose and structure of this book
  • Which libraries we will focus upon
  • What is advanced JavaScript programming?
  • Cross-browser authoring
  • Test suite examples

If you are reading this book, you know that there is nothing simple about creating effective
and cross-browser JavaScript code. In addition to the normal challenges of writing clean
code, we have the added complexity of dealing with obtuse browser differences and
complexities. To deal with these challenges, JavaScript developers frequently capture sets of
common and reusable functionality in the form of JavaScript libraries. These libraries vary
widely in approach, content and complexity, but one constant remains: they need to be easy
to use, incur the least amount of overhead, and be able to work across all browsers that we
wish to target.
It stands to reason then, that understanding how the very best JavaScript libraries are
constructed can provide us with great insight into how your own code can be constructed to
achieve these same goals. This book sets out to uncover the techniques and secrets used by
these world-class code bases, and to gather them into a single resource.
In this book we’ll be examining the techniques that are used to create two of the more
popular JavaScript libraries. Let’s meet them!

翻译
在这一章节:

  • 快速浏览本书结构并介绍本书写作目的
  • 介绍我们将着重讲述的库
  • 什么是高级JavaScript编程?
  • 跨浏览器编程(写作?)
  • 测试包示例

  如果您正在读这本书,您一定知道创造高效运行的、跨浏览器的JavaScript代码并不容易。除了面对编写整洁代码的常规挑战,我们还要面对处理各种不同浏览器之差异造成的复杂性问题。为了应对这些挑战,JavaScript开发人员需要经常使用以JavaScript库形式提供的通用和可重用功能。这些库函数在方法、内容和复杂性各方面都有很大差异,但有一个不变的事实:它们是易用的,运行开销小,并且能在我们需要使用的所有浏览器上正常工作。
  因此,理解那些最优秀的JavaScript库如何构造可以让我们深入了解如何构造您自己的代码以实现上文提到的这些目标。这本书旨在揭示这些世界级的代码库的核心使用的技术和秘籍,并且把它们整合到一个源中。
  在这本书中,我们将研究创建两个更加流行的JavaScript库所使用的技术,让我们见见它们!

原文
1.1 Our key JavaScript libraries
  The techniques and practices used to create two modern JavaScript libraries will be the focus
of our particular attention in this book. They are:

  • Prototype (http://prototypejs.org/), the godfather of the modern JavaScript libraries
    created by Sam Stephenson and released in 2005. This library embodies DOM, Ajax,
    and event functionality, in addition to object-oriented, aspect-oriented, and functional
    programming techniques.
  • jQuery (http://jquery.com) , created by John Resig and released in January of 2006.
    jQuery popularized the use of CSS selectors to match DOM content. Includes DOM,
    Ajax, event, and animation functionality.

  These two libraries currently dominate the JavaScript library market, being used on
hundreds of thousands of web sites, and interacted with by millions of users. Through
considerable use and feedback these libraries been refined over the years into the optimal
code bases that they are today. In addition to detailed examination of Prototype and jQuery,
we’ll also look at a few of the techniques utilized by the following libraries:

  • Yahoo! UI (http://developer.yahoo.com/yui), the result of internal JavaScript
    framework development at Yahoo! and released to the public in February of 2006.
    Yahoo! UI includes DOM, Ajax, event, and animation capabilities in addition to a
    number of pre-constructed widgets (calendar, grid, accordion, etc.).
  • base2 (http://code.google.com/p/base2), created by Dean Edwards and released
    March 2007. This library supports DOM and event functionality. Its claim-to-fame is
    that it attempts to implement the various W3C specifications in a universal, cross-
    browser manner.

  All of these libraries are well constructed and tackle their target problem areas
comprehensively. For these reasons they’ll serve as a good basis for further analysis, and
understanding the fundamental construction of these code bases gives us insight into the
process of world-class JavaScript library construction.
  But these techniques won’t only be useful for constructing large libraries, but can be
applied to all JavaScript coding, regardless of size.
  The make up of a JavaScript library can be broken down into three aspects: advanced use
of the JavaScript language, meticulous construction of cross-browser code, and a series of
best practices that tie everything together. We’ll be carefully analyzing these three aspects
to give us a complete knowledge base with which we can create our own effective JavaScript
code.

翻译
1.1 我们最主要的JavaScript库
  我们在本书中特别关注对象是用于创建两个现代JavaScript库的所使用的技术和实践。它们是:

  • Prototype ,这是现代JavaScript库的代表,由SamStephenson创造,于2005年发布。该库包含了DOM,Ajax和事件功能,还有面向对象,面向切面和基于方法的编程等技术。 (http://prototypejs.org/)
  • jQuery,由John Resig创建,2006年1月发布。jquery推广了使用css选择器来匹配dom内容的技术。dom内容包括dom, Ajax、事件和动画功能。(http://jquery.com)

  这两个库占据了目前JavaScript库主流市场,成千上万的网站使用它们搭建并与数以百万计的用户进行交互。通过大量使用和反馈,这些库改进成为今天我们看到的这样,拥有它们历史上最优的核心代码。除了对Prototype和JQuery进行详细的研究以外,我们还将介绍以下库使用的一些技术:

  • Yahoo!UI 雅虎JavaScript框架开发内部成果!2006年2月发布。Yahoo!UI包含DOM,Ajax,event,动画,还有一系列预先定义的组件(日历,表格,折叠菜单等) (http://developer.yahoo.com/yui)
  • base2 由Dean Edwards创建,2007年3月发布。这一库函数支持DOM和事件响应函数。它出名的地方在于它试图用一种通用的、跨浏览器的方式实施W3C规范。

  所有这些库都构建地很好,彻底解决了它们要解决的问题。基于这些原因,它们将作为进一步分析的良好基础,理解这些库的核心基础代码的构建使我们能够深入了解世界一流的JavaScript库建设过程。
  但是这些技术不仅对构建大型库有用,它们还可以应用于所有JavaScript编码,无论其规模大小。
  一个JavaScript库的构建可以分为三个方面:javascript语言的高级应用、精心构建的跨浏览器代码,以及一系列将一切联系在一起的最佳实践。我们将仔细分析这三个方面,得到一个完整的知识基础,用它我们可以创建我们自己的有效的JavaScript代码。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章