HTML and CSS Reference
In-Depth Information
Chapter 5
Learning Some Helpful Libraries
What's in this chapter?
• Learning jQuery
• Understanding callbacks and events
• Using the Underscore.js utility library
Wrox.com Code Downloads for this Chapter
The wrox.com code downloads for this chapter are found at www.wrox.com/rem-
title.cgi?isbn=9781118301326 on the Download Code tab. The code is in the chapter 05 download and individu-
ally named according to the names throughout the chapter.
Introduction
The most significant barrier, in the pre-Ajax days, to JavaScript becoming a viable platform for interactive cross-
browser application development was the subtle differences between the various browsers. Inconsistent imple-
mentations of assorted features across the various browsers (with Internet Explorer being particularly guilty)
meant that to interact with a web page, developers needed to know the ins and outs of each browser and modi-
fy their code to handle the different incompatible implementations. Combine this difficulty with the verboseness
of manipulating elements on the page and making asynchronous web calls, and it's no surprise people viewed
JavaScript as a toy compared to what people were doing in Java and Flash. That view began to change as librar-
ies, which made the developer experience more consistent and the JavaScript code more concise, began to gain
widespread use.
Learning JavaScript Libraries
jQuery has become the most popular JavaScript library by leaps and bounds, and is used on more than 40% of
all websites in the world (see http://w3techs.com/technologies/overview/javascript_library/all ). It has gained its
popularity for two main reasons: It's good at its job and it's namespace friendly, meaning that you never need to
worry about jQuery getting in the way of your other code. You learn jQuery in this chapter and use it throughout
the topic.
You also learn another smaller library called Underscore.js. Whereas jQuery is concerned primarily with the
manipulation of DOM elements and making Ajax calls, Underscore.js provides a number of utility functions that
make JavaScript a more developer-friendly language, specifically targeted at functional programming. A self-
Search WWH ::




Custom Search