Separating the layers of your web pages makes them more compact and easier to maintain. The Behaviour JavaScript library makes it easy for even beginning coders to do this, and helps seasoned developers save time when building web sites. This article is the first in a three-part series that explains the features of this library.
Introducing the Behaviour JavaScript Library (Page 1 of 4 )
To speak frankly, the Web still contains thousands of web sites that have been poorly developed. Many of them include amateur graphics, implement limited or nonexistent accessibility and usability, and so forth. This becomes even more evident when you take a quick look at their rendered source code.
One of the most critical issues of these web sites is the way that JavaScript code is integrated into the corresponding structural markup. Examining the client-side code of this kind of web site can be a painful experience. There are many messy, inline JavaScript handlers here and there, mixed up with (X)HTML code. And then of course, there is the weak structure of the markup in question. All of these factors speak for themselves about how poorly the pages have been created and designed.
On today's Web the above scenario seems to be unfortunately quite popular. But if you're a conscientious web developer, then you know the importance of building web sites where each one of the layers -- that is, the sections corresponding to visual presentation, behavior and structure respectively -- are completely isolated from each other. This is the best approach to take to keep these web sites compact and highly maintainable.
However, you may be a beginner that still mixes up inline JavaScript event handlers with the structural markup of your web sites, simply because you don't know that these two classes of elements should reside in different layers. So, bearing in mind this eventual possibility, in this three-part series I'm going to show you how to avoid including the aforementioned inline JavaScript handlers by using a compact, tight JavaScript library called "Behaviour."
The Behaviour package has been created by Ben Nolan (please visit http://www.bennolan.com/behaviour/ for more information). It boasts a bunch of remarkable features which will let you separate the (X)HTML and JavaScript code corresponding to your web site very easily. It's particularly useful when it comes to assigning event handlers to one or more elements of different web documents.
Having introduced the main characteristics that this powerful JavaScript package offers, now let's move on and start learning together how to take advantage of its numerous and handy features. Let's begin now!