Skip to content
chuckdumont edited this page Oct 18, 2012 · 45 revisions

This wiki is under construction

The purpose of this wiki is to provide useful information about the Javascript Aggregator (JAGGR) project. JAGGR (or, throughout this wiki, the Aggregator) is an OSGi servlet that provides aggregation and code minification services to an AMD loader that supports the loader extension API. At the time of this writing, the Dojo loader in Dojo 1.7.3 and 1.8 supports this API, and Dojo 1.7.1 or 1.7.2 may be used with this patch http://bugs.dojotoolkit.org/ticket/14198.

What is AMD?

AMD stands for Asynchronous Module Definition. The AMD API specifies a mechanism for defining modules such that the module and its dependencies can be asynchronously loaded. Organizing JavaScript code into modules aids development by promoting modularization and code reuse, but can result in an excessive number of requests, impacting the performance of web applications.

There are two general approaches to resolving this problem:

  • Static layer builds - collections of minified and aggregated modules organized into pre-defined layers that are defined by developers
  • On-demand module aggregation and minification performed by some server-side process

Aggregator Features

The Aggregator is an instance of the later approach. It utilizes a client-side component that hooks into extensions provided by an AMD loader in order to collect and combine requests for multiple modules into a single HTTP request/response. In addition to module aggregation, the Aggregator also provides:

##Extensibility

The Aggregator supports extensibility through the eclipse extension registry which is supported by the OSGi framework. Three extension points are provided. They are:

  • com.ibm.servlets.amd.aggregator.resourcefactory - Provides the ability for third-parties to support resources in alternate repositories such as jar files, databases, etc. By default, the Aggregator supports resources on the server's file system and in OSGi bundles.
  • com.ibm.serlvets.amd.aggregator.modulebuilderfactory - Provides the ability for third-parties to support build/minification of resource types specified by file extension (e.g. css, html, etc.). The Aggregator provides default implementations for the javascript and css builders.
  • com.ibm.servlets.amd.aggregator.httptransport - Enables third parties to provide named HTTP transport implementations. The HTTP transport is the component responsible for extending the client loader, forming the HTTP requests to the server and on the server, for parsing and interpreting the request

Transparency

A major design goal for the project is that it's use is transparent to the application. This means that the Aggregator does not impose any coding requirements or provide any API for use by the client application (other than requiring a loader config property). If your application is written to use an AMD loader, and that loader supports the loader extension API, then you may start using the Aggregator by providing a bit of config information and loading the script that contains the loader extension code. And you can easily switch between using, or not using, the Aggregator simply by choosing whether or not to load the loader extension code.