Namespace.js: take a wild guess….
Let’s lead with code:
PLAIN TEXT
JAVASCRIPT:
-
Namespace(‘foo.bar’);
-
foo.bar.myFunction = function() {};
-
Namespace(‘com.example’, {
-
MyClass: function() { return {}; }
-
});
-
var obj = new com.example.MyClass();
-
Namespace.use(‘com.example.MyClass’);
-
var obj2 = new MyClass();
-
// include com/example/RemoteClass.js
-
Namespace.include(‘com.example.RemoteClass’);
-
var obj3 = new com.example.RemoteClass();
-
Namespace.registerNativeExtensions();
-
‘com.foo.bar’.namespace();
Reading the code above is probably all you need to know about the new, library independant, JavaScript library Namespace.js, created by Maxime Bouroumeau-Fuseau.
The goals for the library are:
- Simple API
- Framework independent
- Remote file loading (synchronously or async)
- Tested against Firefox 3.x, Safari 3.x, IE 6/7 and Opera 9.5
- Highly configurable
- Events
- Optionally add methods to native objects
You can see more in the How To.