Scriptaculous allows you to easily add powerful AJAX-based user interface features to Web 2.0 applications. Web developer Tony Patton explains why you should use it and describes how to use it.
What is it?
Why use it?
AJAX is a great marriage of technologies, but it can be confusing and time-consuming to build AJAX-powered applications from scratch. The scriptaculous framework makes it easy to include AJAX-based features in your applications, plus all of the development and testing has been done, so you can devote your time to more important tasks.
- scr\bulder.js: Allows you to easily create DOM elements dynamically.
- src\controls.js; Includes the core components for working with the custom data controls.
- src\dragdrop.js: Provides the code for utilizing the custom data controls for drag-and-drop related functions.
- src\scriptaculous.js: The base code library for utilizing the scriptaculous framework.
- src\slider.js: Provides the code for utilizing the slider data control.
You may be wondering about the overhead of including these files in a Web page. The complete library (all files in the list) consumes approximately 150KB. The two core files—prototype.js and scriptaculous.js—add up to 50KB. So, all other combinations will be between 50 and 150KB depending on the files used.
The various functions available are accessed via HTML script tags. You can gain a better understanding by examining one of the test files installed with the framework (or an online example). As an example, I loaded the slider_test.html file located in the test\functional directory of a default installation. The complete contents of the file are too much to list here, but I can examine one portion that loads the first slider control on the page—a standard horizontal slider:
A drawback of many freely available (and some commercial) tools is a lack of documentation and examples. The scriptaculous framework includes extensive example code and basic documentation via its Wiki. In addition, a quick Google search yields more help. A good example is the various cheat sheets available that provide a quick reference sheet for using the framework.
The framework includes an extensive set of examples that are included in the functional subdirectory of the test directory. You can dive into the test files to get a good idea of how to use framework functions within your application. In addition, the demos section of the scriptaculous Web site provides great examples.
Who uses it?
There are plenty of freely available tools and libraries on the Web, but you can get an idea of a tool's acceptance by examining who uses it and how they use it. The scriptaculous framework is currently being used by various Web sites in one form or another. The sites include Apple, The Globe and Mail newspaper, NBC News, and Basecamp. A more comprehensive list is available on the site.
Project timelines continue to shrink as user expectations rise, but free tools and frameworks make it easy to add features to an application. Scriptaculous is a good example of a framework that allows you to easily add powerful AJAX-based user interface features to Web 2.0 applications. I'll offer more examples of framework usage in next week's article.
Miss a column?
Check out the Web Development Zone archive, and catch up on the most recent editions of Tony Patton's column.
Tony Patton began his professional career as an application developer earning Java, VB, Lotus, and XML certifications to bolster his knowledge.