Chapter 1. jQuery extensions

 

This chapter covers

  • jQuery’s origins and purpose
  • What you can extend in jQuery
  • Examples of existing extensions

Today, jQuery is the most widely used JavaScript library on the web. It offers many functions to make life easier as a front-end developer, such as the ability to traverse the HTML Document Object Model (DOM) to find the elements you want to work with and apply animations to those elements. Moreover, the developers of jQuery have recognized that it can’t (and shouldn’t) do everything, and have provided extension points that allow additional functionality to be integrated into the normal jQuery processing. This foresight has contributed to its popularity.

In this book I explain how you can extend various aspects of jQuery to provide greater reuse and easier maintenance of your code. Alongside the standard plugin that operates on a collection of elements on a web page, you can create custom selectors, utility functions, custom animations, enhanced Ajax processors, custom events, and validation rules. I cover testing, packaging, and documenting your code to make sure that others can make maximum use of it as well.

1.1. jQuery background

The jQuery website defines jQuery as “a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers” (http://jquery.com).

1.2. Extending jQuery

1.3. Extension examples

1.4. Summary