Inject is a CommonJS Compliant loader that runs in the browser and makes dependency management ridiculously easy. Read on to find out how.
The dependency management problem
The Inject solution
With Inject, adding program.js is a no-brainer: you just load Inject on your page, specify the root path for your modules, and then call run.
And that's it! The dependency management downstream from program.js is totally transparent. This is because the modules themselves specify their dependencies using the require keyword. For example, program.js specifies its dependency on hello.js:
In turn, hello.js specifies its dependency on name.js:
Inject finds the dependencies automatically and loads them asynchronously. If a developer changes some downstream dependency - for example, changes hello.js to depend on new-name-module.js instead of name.js - your code will keep working because Inject will automatically find and download the new dependencies on the next page load.
Inject is a young library, but it already supports a significant feature list:
- Simple interface
- Modular code that doesn't pollute the global namespace
- CommonJS compliant
- Supports the AMD API
- Supports "bundled" files (multiple files concatenated)
- Supports single-file retrieval during development
- Works cross-domain
- Takes advantage of modern browser features where possible (e.g. postMessage and localStorage)
Using Inject, we have a much more maintainable solution and we're excited to share it with the open source community.
Try it out!
Here's everything you need to take Inject for a test drive:
Our goal with Inject is to build a dependency management library that presents a very simple interface but can still support the variety of complex situations that we face with a site like LinkedIn. It's a balance we're going to strive to maintain as we continue to grow the project, and we'd love some help!