Dependency Management Got Awesome CommonJS and AMD Compliant dependency loader for modern web apps

Using Inject on Multiple Domains


OLD: This is an old version of documentation. You probably want the most recent version of this document, from the sidebar on the right.

In large site deployments, it may be necessary to run Inject using a Content Delivery Network (or “CDN”). Many times, the use of a CDN puts resources on a server and domain different than the main page. This howto is all about how you set up Inject to work in a CDN environment.

We’re going to assume you have two servers:

  • is your website
  • is your CDN location (and the scripts are under /js/modules)

What to Upload Remotely

On the remote server, you’ll need to upload two files, the relay.swf and the relay.html file onto your CDN. For simplicity sake, we’re going to put these in your module’s root directory.

# server:

What’s important is that you can put the URL to your CDN into your browser and reach the two files. In the above case, you should be able to reach and via a normal web browser.

Configuring Inject

Given the CDN location, we will need to use both Inject.setModuleRoot and Inject.setCrossDomain to configure this installation of Inject. setModuleRoot tells Inject your files are on another server, while setCrossDomain tells inject where the two helper files are that it will need for cross-domain downloading.

  relayFile: '',
  relaySwf:  ''
comments powered by Disqus