Loader can be used programatically as an offline dependency calculator.
Loader comes with the `YUI` seed file by default, so it's ready to be used immediately, so there is no need to load any additional files.
``` var Y = YUI(); var loader = new Y.Loader(); ````Loader` comes with a `resolve` method that it uses internally to calculate dependencies and build URL's for injecting scripts into the page.
``` var Y = YUI(); var loader = new Y.Loader({ require: [ 'node' ] }); //Tell loader to calculate dependencies loader.calculate(); var out = loader.resolve(); ```In the above code, `out` will be an Object containing the keys, `js` and `css` that will contain an array of URL's to load the modules needed to resolve `node`.
The above code will generate this URL for you:
You can use any `Loader` configuration option here as well: `modules`, `groups`, `patterns`, etc.
Here we use Loader to calculate dependencies from the command line and generate a combined file. This could be used in a build system to auto-generate a custom seed file with modules needed for immediate access.
``` {{>loader-resolve-node}} ```