HTML and CSS Reference
In-Depth Information
What Are JavaScript Libraries?
In this topic, I've talked about browsers and incompatibilities between them. The popular
browsers differ in their support for HTML and CSS, and also in their support for
JavaScript. Unlike CSS and HTML, though, JavaScript can actually be used to solve the
problem of implementations of JavaScript that differ in small but important ways. You
can write programs that detect which browser is being used, or even the specific capabili-
ties of the browser being used and then add logic to make sure the program works cor-
rectly for whatever environment that it's in.
For example, some browsers allow you to retrieve elements from the document by class
name using the getElementsByClassName() method, and others do not. If your script
depends on that method, it will break in some browsers. You can work around the prob-
lem by checking to see whether the method exists before you use it, and if it doesn't,
using another technique that works in the browsers that don't support it.
JavaScript libraries were created by people who had to do this sort of thing too many
times and decided to package up all these kinds of workarounds to create a simpler inter-
face to common functionality that hides all the incompatibilities of the various browsers.
In doing so, the authors also added many other features to make life more convenient for
JavaScript developers. The most popular JavaScript libraries all make it easier to bind
code to events, select elements on the page to act on in your programs, and even make
calls to the server from JavaScript to dynamically change elements on the page, using a
technique referred to as AJAX.
You might have noticed that I am referring to JavaScript libraries as a group. That's
because there are a number of libraries that provide roughly the same set of features.
They were all independently developed and work differently from one another; each has
its own set of advantages and disadvantages. If you're starting from scratch, choosing
between them is a matter of taste.
Reviewing the Popular JavaScript
Libraries
In this lesson, the examples are written in jQuery, but they could have been written in
any of the popular JavaScript libraries. Here's a quick overview of the most popular
libraries that people are using. All these libraries are open source, free software that you
can use on your own website, even if it's a commercial site.
 
 
 
Search WWH ::




Custom Search