Skip to content
This repository was archived by the owner on Apr 16, 2019. It is now read-only.

Low-level API to build urls for js and css yui modules

Choose a tag to compare

@caridy caridy released this 18 Jul 18:40
· 205 commits to master since this release

In some cases, you want to produce urls to preload yui modules or yui css modules. Since all those modules are part of the meta generated by app.yui.plugin() thru Locator, and we also have access to each group and the configuration of those groups from app.js, we can generate those urls easily.

To build a list of urls to load a list of yui modules:

var scripts = app.yui.buildJSUrls('node', 'photos@hermes');

As a result, scripts will be an array with one or more urls that you can use in your templates to insert script tags. Modules as photos@hermes denotate a module from a particular group,
as in <module-name>@<group-name>. Modules without the group denotation
will be assumed as core modules from yui.

To build a list of urls to load a list of yui css modules:

var links = app.yui.buildCSSUrls('cssbase', 'cssflickr@hermes');

As a result, links will be an array with the urls that you can use in your templates to provision styles.

Modules as cssflickr@hermes denotate a module from a particular group, as in <module-name>@<group-name>. Modules without the group denotation will be assumed as core modules from yui.

Other notes:

  • dependencies computation is not part of the deal, you have to deal with that, both method are expecting the final list of modules to generate the urls.
  • depending of the configuration in app.js the urls returned by both methods will be combo urls or not.
  • the data under window.YUI_config.seed, which is part of the state object, is now using buildJSUrls under the hood to produce the seed urls.