- AJILE
Infobox Software
name = Ajile
caption = Ajile's Official Site
developer = Michael A. I. Lee
released =November 19 ,2003
latest_release_version = [http://prdownloads.sourceforge.net/ajile/Ajile.1.2.1.zip?download 1.2.1]
latest_release_date =December 30 ,2007
operating_system =Cross-platform
genre =JavaScript
license = MPL 1.1 / LGPL 2.1 / GPL 2.0
website = [http://ajile.iskitz.com/ ajile.iskitz.com]Advanced JavaScript Importing & Loading Extension is the browser-independent extension that provides
JavaScript with namespace and dynamic script loading support. It is an open-source solution developed and maintained by Michael Lee and is released under the MPL 1.1, LGPL 2.1, and GPL 2.0 tri-license.= Background =
JavaScript's ease of use as a web development language has led to the availability of countless scripts. Most scripts are well designed for the problem they address, but poorly designed for coexistence and interoperability. As web development has advanced, it has become standard practice to combine many such scripts within a single web page, site, or application. Such combination often introduces scope control issues that can require substantial time and effort to identify, understand, and resolve.
Many development languages such as Java, C#, and C++ provide language constructs specifically aimed at managing scope and interoperability. These constructs typically implement the concept of namespaces and namespace member access. JavaScript, as defined by the
ECMAScript [http://www.ecma-international.org/publications/standards/Ecma-262.htm Language Specification (3rd Edition)] , does not provide such constructs. [cite web
title = Standard ECMA-262 ECMAScript Language Specification 3rd edition (December 1999)(December 1999)
url=http://www.ecma-international.org/publications/standards/Ecma-262.htm
accessdate = 2007-10-06 ]In November 2003 Michael Lee created [http://projects.sourceforge.net/jspackaging/ JSPackaging] as a
cross-browser JavaScript namespace solution. JSPackaging provided JavaScript with language constructs that allowed defining a namespace, accessing its members, and loading externally defined arbitrary or namespaced modules from any local or network accessible location.In September 2005 Michael enhanced JSPackaging with
Model-View-Controller support and released it under the name Ajile. The name Ajile was chosen as a play on the word agile, meaning fast, light and nimble; an accurate description of the solution and its effect.Ajile implements the
Model-View-Controller design pattern for client-side web development to facilitate:* Total separation of display and business logic.
* Easy interaction of display and business logic in a loosely coupled fashion.
* Minimized impact whenever the display and/or business logic changes.
* Focused display troubleshooting and targeted business logic debugging.Ajile's MVC implementation allows scripts and web pages to be completely separated by becoming each page's main controller. As the main controller, Ajile links pages with external scripts that define the page's behavior and data models. These external scripts can be arbitrary non-namespaced scripts or modules that make use of any or all of Ajile's features.
= Features =Ajile enhances JavaScript's effectiveness as a web application development language by providing the following powerful and easy to use features:
* Namespacing
* Dynamic Script Loading
* Packaging
* [http://ajile.iskitz.com/docs/api/Directives.htm#Include Module Including]
* Module Importing
* Module Importing with Aliases
* [http://ajile.iskitz.com/docs/api/Functions.htm#AddImportListener Module Import and Include Notification]
* Runtime Dependency Enforcement
* [http://ajile.iskitz.com/docs/api/Options.htm#refresh Cache Management]
* [http://ajile.iskitz.com/docs/api/Functions.htm#Unload Memory Management]
* [http://ajile.iskitz.com/docs/api/Options.htm#cloak Source Code Cloaking]= Compatibility =Ajile is compatible with the following specifications and
web browsers :Specifications
* ECMA-262, Edition 3+
* JavaScript 1.3+
*JScript 3.0+Desktop Browsers
*
Camino 1.0.1+
*Firefox 0.7+ ,Mozilla Firebird 0.6+,Mozilla Phoenix 0.1+
*iCab 3.0.3+
*Internet Explorer 4.01+
* Mozilla 0.9.1+
* Netscape 6+
*OmniWeb 5.6+
* Opera 5+
* Safari 1.2+
*SeaMonkey 1.0+
*Shiira 1.2.2+
* [http://sunrisebrowser.com/en/ Sunrise] 0.89+Mobile Browsers
* Blazer 3.0 on Treo 600
*Opera Mini 2.0+
* Safari on iPhone= Usage =
Ajile can be used with both inline scripts and external scripts, but is most effective when using external scripts. To begin using Ajile:
* First include Ajile within a web page as follows:* Next, create an external script file with the same name as the web page (i.e. MyPage.js if the web page is named MyPage.htm); doing this triggers Ajile's MVC support. Ajile will now automatically load this external script whenever the web page is loaded.
* When Ajile is used without external scripts its MVC support should be explicitly disabled by changing its script tag in the web page as follows:
* Ajile is now ready for use. Please read the following sections for details on its use within your web page's scripts.
Loading a Script
Ajile provides the
Load
directive for loading arbitrary scripts. The following example demonstrates its use:In the above example the
LoadExample.js
script is dynamically loaded into the current web page. TheLoad
directive provides a way for a script (inline or external) to programmatically load any JavaScript file or code fragment. It eliminates the need to continuously modify web pages everytime their script list changes. TheLoad
directive gives scripts the power to define exactly which scripts get loaded at runtime.Defining a Namespace
Ajile provides the
Namespace
directive for defining namespaces. The following example demonstrates its use:In the above example the
com.iskitz.ajile.examples
namespace is created and theNamespaceExample
module is added to it. A reverseddomain name is used as the namespace to assure that the module is uniquely named. The ability to uniquely identify modules is especially important when using multiple modules from varied sources within the same page or site.When working with modules within an
Intranet or non-Internet environment, it may be sufficient to use simpler namespaces. Ajile provides the flexibility to create as simple or as complex a namespace as desired.Packaging a Module
Once a module has been created as shown in the "Defining a Namespace" section, it is important to package the module so that it can be included or imported. Ajile supports the use of "Fully-Qualified File Name" and "Directory-Based" packaging.
Fully-Qualified File Name
To package the NamespaceExample module shown in the "Defining a Namespace" section using the "Fully-Qualified File Name" approach, save the module's source code in a file named:
com.iskitz.ajile.examples.NamespaceExample.js
Next, place that file in the same directory as the Ajile module as follows: .NOTE: Ajile supports naming the file using any valid operating system filename character in place of the dot (.) character except immediately before the file's extension i.e.:
com_iskitz_ajile_examples_NamespaceExample.js
Directory-Based
To package the NamespaceExample module shown in the "Defining a Namespace" section using the "Directory-Based" approach, save the NamespaceExample module's source code in a similarly named file within the Ajile module's directory as shown here: .
Importing a Module
As effective as namespaces can be in promoting interoperability, they can complicate development by requiring the use of long module names. Ajile addresses this issue by providing the
Import
directive.The
Import
directive provides these key benefits:* Simple names to reference uniquely named JavaScript modules.
* Simple definition of JavaScript module dependencies.
* Simple programmatic loading of external JavaScript modules.Example
The following code demonstrates how the
Import
directive is used:TheImport
directive in the code above indicates that there is a dependency that must be imported. The externally definedcom.iskitz.ajile.examples.Complex.js
JavaScript module is automatically imported and made accessible via its short name,Complex
. The importedComplex
module is then used by thetestImport
function.Complex Module
The following is the content of the
Complex
module:TheImport
directive in the code above automatically imports the externally definedcom.iskitz.ajile.examples.Simple.js
JavaScript module then makes it available via its short nameSimple
.Simple Module
The following is the content of the
Simple
module:Importing with Aliases
When importing multiple modules it is possible to encounter naming conflicts. Ajile provides the
ImportAs
directive as a solution to this problem.The
ImportAs
directive provides two benefits in addition to those provided by theImport
directive:* Flexibility to import a module using any un-used short name.
* Ability to handle naming conflicts by assigning aliases to similarly named modules.Example
The following code demonstrates how the
ImportAs
directive can be used to handle module naming conflicts:In the code above, two modules with the identical short nameComplex
are imported. TheImport
directive automatically imports the externally definedcom.iskitz.ajile.examples.Complex.js
JavaScript module as is. TheImportAs
directive also automatically imports the externally definedcom.iskitz.ajile.examples.ambiguity.Complex.js
JavaScript module but performs the extra step of assigning it theAComplex
alias.By assigning the
AComplex
alias to the importedcom.iskitz.ajile.examples.ambiguity.Complex
module, thetestAmbiguity()
function is able to reference both modules without encountering naming conflicts.AComplex Module
The following is the content of the
AComplex
module:= Release History =
* [http://prdownloads.sourceforge.net/ajile/Ajile.1.2.1.zip?download Ajile 1.2.1] ,December 30 ,2007
* [http://prdownloads.sourceforge.net/ajile/Ajile.1.1.5.zip?download Ajile 1.1.5] ,December 25 ,2007
* [http://prdownloads.sourceforge.net/ajile/Ajile.0.9.9.2.zip?download Ajile 0.9.9.2] ,October 5 ,2007
* [http://prdownloads.sourceforge.net/ajile/Ajile.0.9.9.1.zip?download Ajile 0.9.9.1] ,September 28 ,2007
* [http://prdownloads.sourceforge.net/ajile/Ajile.0.9.9.zip?download Ajile 0.9.9] ,September 16 ,2007
* [http://prdownloads.sourceforge.net/ajile/Ajile.0.9.8.zip?download Ajile 0.9.8] ,September 4 ,2007
* [http://prdownloads.sourceforge.net/ajile/Ajile.0.9.5.zip?download Ajile 0.9.5] ,July 30 ,2007
* [http://prdownloads.sourceforge.net/ajile/Ajile.0.9.zip?download Ajile 0.9] ,July 24 ,2007
* [http://prdownloads.sourceforge.net/ajile/Ajile.0.7.9.zip?download Ajile 0.7.9] ,March 11 ,2007
* [http://prdownloads.sourceforge.net/ajile/Ajile.0.7.8.zip?download Ajile 0.7.8] ,December 29 ,2006
* [http://prdownloads.sourceforge.net/ajile/Ajile.0.7.5.zip?download Ajile 0.7.5] ,December 16 ,2006
* [http://prdownloads.sourceforge.net/ajile/Ajile.0.7.zip?download Ajile 0.7] ,September 28 ,2006
* [http://prdownloads.sourceforge.net/ajile/Ajile.0.6.5.zip?download Ajile 0.6.5] ,September 11 ,2006
* [http://prdownloads.sourceforge.net/ajile/Ajile.0.6.2.zip?download Ajile 0.6.2] ,August 2 ,2006
* [http://prdownloads.sourceforge.net/ajile/Ajile.0.5.5.zip?download Ajile 0.5.5] ,July 11 ,2006
* [http://prdownloads.sourceforge.net/ajile/Ajile.0.5.zip?download Ajile 0.5] ,June 8 ,2006
* [http://prdownloads.sourceforge.net/ajile/Ajile.0.4.zip?download Ajile 0.4] ,January 22 ,2006
* [http://prdownloads.sourceforge.net/ajile/Ajile.0.3.7.zip?download Ajile 0.3.7] ,November 1 ,2005
* [http://prdownloads.sourceforge.net/ajile/Ajile.0.3.6b.zip?download Ajile 0.3.6b] ,September 30 ,2005
* [http://prdownloads.sourceforge.net/ajile/Ajile.2.1.zip?download JSPackaging 2.1] ,May 5 ,2004
* [http://prdownloads.sourceforge.net/ajile/JSPackaging.2.0.zip?download JSPackaging 2.0] ,February 8 ,2004
* [http://prdownloads.sourceforge.net/ajile/JSPackaging.1.0.zip?download JSPackaging 1.0] ,November 19 ,2003 = References =
= Further Reading =
* [http://www.sitepoint.com/books/jsant1/ The JavaScript Anthology: 101 Essential Tips, Tricks & Hacks] , ISBN 0975240269= External Links =
* [http://ajile.iskitz.com/ Ajile's Official Site]
* [http://sourceforge.net/projects/ajile/ Ajile's Project Site]
* [http://help.ajile.iskitz.com/ Ajile's Support Site]
Wikimedia Foundation. 2010.