Java Reference
In-Depth Information
released IE7. This new version included many bug fixes, as well as the implementation of new (and
often nonstandard) features.
This was the beginning of a very challenging time for JavaScript developers. The problem with
client‐side development was the many different web browsers developers needed to support. Not
only did developers have to support IE and Firefox, but developers had to support three major
versions of IE (6, 7, and 8). Be it writing event‐driven code or an Ajax application, somewhere down
the line developers ran into the many incompatibilities between different browsers and versions.
Many professional developers found cross‐browser development to be too time‐consuming and
cumbersome to deal with on a daily basis, so they set out to develop frameworks or libraries to aid
in their cross‐browser development. Some developers released their frameworks to the public, and
a few of them gained quite a following. And much like the browser wars of old, eventually a victor
emerged. Frameworks such as MooTools and Prototype were quite popular, but jQuery became the
de facto standard.
jQuery, like most other frameworks, originated as an Ajax library to simplify client/server
communication. Today, however, jQuery simplifies just about every common aspect of JavaScript
development; DOM manipulation, Ajax, animation, and component development are much easier
with jQuery. In this chapter, you look at jQuery and learn how to use it to simplify your JavaScript
development.
Before beginning, a word of note: There is no doubt that jQuery adds benefit to your development
time and process. But it is not a substitute for a solid understanding of the JavaScript language and
the intricacies of the different browsers for which you have to develop. Frameworks and libraries
come and go, but knowledge (and pure JavaScript) is forever.
GettinG jQuerY
Installing jQuery (or any framework for that matter) is very different from installing an application
on your computer; there is no setup program, and the installation doesn't change any portion of
your system. Basically, all you do is reference the jQuery JavaScript file in your web page.
Open your browser and go to http://jquery.com/download/ . On this page, you'll find several
links to different jQuery‐related files. First, you'll see two versions of jQuery: 1.x and 2.x. The two
versions are almost identical except that v1.x supports IE 6, 7, and 8 and v2.x does not.
Second, you'll need to choose the compressed or uncompressed version:
Compressed version: This is minified; (all comments and unnecessary white space are removed
from the code files) to make their size as small as possible; doing so makes them faster to
download when someone visits your web page. Unfortunately, the minification process
makes the JavaScript code difficult to read if you open it in a text editor, but that's a reason-
able trade‐off in a production environment.
Uncompressed version: This is not minified; it is simply normal JavaScript code files with
their white space and comments intact. It's perfectly OK to use uncompressed JavaScript files.
Because they are easier to read than compressed files, you can learn much from the gurus
who design and develop these frameworks. However, if you plan to roll out a web page using
 
Search WWH ::




Custom Search