
The ultra lightweight JavaScript library
Introduction
AJS is a ultra lightweight JavaScript library that is around 1 and half year old. It is hugely inspired by MochiKit, but differs by being small. The current version is only 33 KB (uncompressed), whereas MochiKit is over 100 KB.
AJS includes:
- Powerful and easy to use AJAX functions
- Effects
- Drag and drop
- Useful array functions such as AJS.flattenArray
- Functional programming such as AJS.map
- DOM functions such as AJS.$
- AJAX JSON support (with AJS.loadJSONDoc and AJS.serializeJSON)
- Unified position and size that works in all the modern browsers
- Unified events that work in all the modern browsers
- and a lot more...
But that's not all! AJS also features:
- Only ONE namespace is used, namely AJS
- Documentation and examples on all functions
- Polymorphic - A Python script can scan your code, find the AJS functions you use and create a special AJS file for you that is MUCH smaller!
Code snippets
Creating DOM smartly
var p_elm = P(SPAN({'class': 'blue_n_black'}, IMG({'src': 'hottie.gif'})));
AJAX done easily
function doSearch() {
var url = "http://api.search.yahoo.com/";
var d = AJS.loadJSONDoc(url);
d.addCallback(function(o) { alert(o); });
var form = AJS.$('formy');
d.sendReq({appid: "YahooDemo",
query: AJS.$f(form, 'q').value,
results: AJS.$f(form, 'r').value,
output: "json"})
return false;
}
RND templates
var tmpl = '<a href="%(link)">%(value|parseInt)</a>'
var name_space = {'link': 'http://amix.dk', 'value': 5.5}
var r = AJS.RND(tmpl, name_space)
//r equals <a href="http://amix.dk">5</a>
Nested effects
var div = AJS.$('div');
AJS.fx.setHeight(div, {
from: 0,
to: 500,
onComplete: function() {
AJS.fx.setWidth(div, {
from: 200,
to: 600,
duration: 1000,
onComplete: function() {
AJS.fx.highlight(div);
}});
}});
Documentation
- AJS reference - Use this to get an overview over functions that AJS provides
- AJS.fx reference - Use this to get an overview over effects
- AJS.dnd reference - Use this to get an overview over drag and drop
Examples
Blog posts
- Solving scoping issues using AJS.bind - A blog post by me that introduces the problem and how it's solved in AJS
- JavaScript OOP - the smart way
- AJS gets effects
Browsers supported
- Firefox 1,0 and 1.5
- IE 5.5 and 6.0
- Netscape 7
- Safari
- Opera 8.5 and 9
- And others...
Where it's used?
Download
This zip file includes AJS.js, AJS_minify.py, documentation and examples:
- Download latest AJS [v4.1]