Skip to content

freedom.js structure: Resource Manager

willscott edited this page Sep 19, 2014 · 1 revision

Resource Manager Code

The freedom.js resource manager is the code class responsible for locating and loading resources for freedom.js modules. We centralize this logic because it allows us to assume that no external resources will be accessed from freedom modules except for through requests to the resource manager. The manager exists outside of the module context, and requests originating inside of the module will be sent out to the Module Interface, which will forward them on to the Resource Manager.

Resource Loading

Resources are loaded by freedom.js in two steps. All resources will first be 'resolved'. This means that resolve is called to determine the absolute URL corresponding to a URL included in a freedom module, as denoted by its canonical URL. Included by default is an HTTP resolver, which does standard relative URL resolution for HTTP-type schemes.

Extending the Manager

The Manager is pluggable, allowing runtime environments to override the default code for resolving and loading resources. This is done by calling addResolver and addRetriever on the resource manager.