jspkg Documentation

Architecture Components

jspkg consists of three major components that handle the resolution, loading and management of packages: the jspkg engine, the package loaders and the script loaders.

jspkg Engine

The jspkg engine is responsible for maintaining the list of packages and their dependencies. As packages are loaded, the engine initializes other packages that depend on the newly-loaded package as necessary.

When a package is requested by the application, jspkg consults the list of package loaders to determine the appropriate package loader to call to resove the package.

Package Loaders

A package loader is responsible for resolving a package of a given name to the specific Javscript file to load the package's source for. Each package loader is assigned to a specific part of the package namespace hierarchy by specifying a pattern of packages for which it resolves.

A user may wish to define a specific package loader that loads a number of scripts from a server-side script.

Script Loaders

A script loader is used by jspkg to take a path to a script and ensure that it is loaded into the scripting environment. The script loader is used by all package loaders to perform the linking of the package script into the environment.

Most users of jspkg will not need to create a script loader, unless they are developing within a non-HTML environment (such as SVG or an embedded Javascript engine).

Examples of script loaders include: