
The ultra lightweight JavaScript library
Introduction
AJS is a ultra lightweight JavaScript library that is around 2 years old. It is inspired by MochiKit, but differs by being small and expressive. The current version is only 33 KB (uncompressed!), whereas MochiKit and other libraries such as JQuery, Mootools or Prototype is over/around 100 KB.
AJS includes:
- Powerful and easy to use AJAX functions
- Performance on almost everything
- Effects
- Drag and drop
- Functional programming such as AJS.map, AJS.partial
- DOM functions such as AJS.$
- AJAX JSON support (with AJS.loadJSON 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'})));
Expressive
//Delete all span elements with class "name" and fluffy_id element
removeElement($bytc('span', 'name'), $('fluffy_id'));
AJAX done easily
function doSearch() {
var url = "http://api.search.yahoo.com/";
var d = AJS.loadJSON(url);
d.addCallback(function(o) { alert(o); });
d.addErrback(function(err) { alert(err); });
var form = AJS.$('formy');
d.sendReq({appid: "YahooDemo",
query: AJS.$f(form, 'q').value,
results: AJS.$f(form, 'r').value,
output: "json"})
return false;
}
Effects
AJS.fx.setHeight(AJS.$('div'), {from: 0, to: 500});
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 newest version of AJS
This zip file includes AJS.js, AJS_minify.py, documentation and examples: