Ch. 21: An Introduction to JavaScript Libraries and Frameworks

• Understand the role of JavaScript programming libraries and frameworks.

•  Understand how to define your own library.

• Understand the role of third-party JavaScript libraries and frameworks and how to find more information about them.

Understanding Programming Libraries

• Library/Framework

- A library is a grouping of code that provides common or additional functionality.

- Within a program, a developer includes or calls the library to use these additional objects and functions.

Defining Your Own JavaScript Library

• Personal Library

- Creating a personal library, or grouping, of common functions that you can use in future projects is helpful.

Example)

Chaper21\CompletedCode\library.js

Chaper21\CompletedCode\librarypage.htm

// Load the page librarypage.htm in a web browser.

- Take care when defining and using your own libraries so that you don’t overlap or collide with existing functions and reserved words from the ECMA-262 specification.

- Additionally, if you use an external library or framework such as jQuery or YUI, you need to make sure that your library doesn’t collide with the naming conventions used for those.

Looking at Popular JavaScript Libraries and Frameworks

- Their goal is to take difficult tasks and make them easier for programmers developing JavaScript-centric web applications.

e.g., A significant advantage to using many JavaScript libraries or frameworks is that they remove the cross-browser compatibility headaches.

e.g., Servlet and JSP

• jQuery

- Using jQuery, which is contained in a single JavaScript file, you can add effects to your web pages, enhance usability, and make processing of data with AJAX easier.

- http://jquery.com

• Yahoo! User Interface (YUI)

- Like jQuery, YUI includes features for enhancing usability and improving the web application.

- http://developer.yahoo.com/yui/

• MooTools

- MooTools differs from YUI and jQuery because it concentrates on optimizing JavaScript processing, whereas YUI and jQuery focus on effects, CSS, and direct user-experience interactions.

- That’s definitely not to say that MooTools doesn’t have effects—MooTools also offers many of the same effects (such as an accordion and a slider) that you find in YUI and jQuery.

- MooTools is recommended for intermediate to advanced JavaScript programmers.

- http://mootools.net/

• Other Libraries

- There are numerous other libraries and frameworks available for JavaScript—too many to cover.

- http://en.wikipedia.org/wiki/Comparison_of_JavaScript_frameworks