Manage Libs Versions
Easily create a list of Radio Inputs to let user choose Library Versions, retrieve the selection and prepare a list of Assets to be dynamically loaded.
The Assets list can be directly passed to
loadJsCss.list()
function.
Quick usage guide
This library uses a UMD wrapper.
If directly loaded into a browser, it assigns the manageLibsVersions
global variable.
Example
HTML
JavaScript
var lib1PathTemplateCss = 'https://unpkg.com/lib1@{{VERSION}}/dist/lib1.css';var lib1PathTemplateJS = 'https://unpkg.com/lib1@{{VERSION}}/dist/lib1.js'; var lib2PathTemplateJs = 'https://unpkg.com/lib2@{{VERSION}}/dist/lib2.js'; var bundle = name: 'bundle' libs: name: 'lib1' mandatory: true versions: name: 'v2.0.0' defaultVersion: true // If no Version is specified, or the specified one is unknown, use this Version instead. assets: manageLibsVersions manageLibsVersions name: 'v1.0.0' defaultVersion: false disabled: true // This will make the Radio Input disabled. assets: manageLibsVersions manageLibsVersions name: 'lib2' versions: name: 'dev' assets: type: 'script' path: '../dist/bundle.js' name: 'v0.15.2' assets: manageLibsVersions ;
HTML
Choose a version for lib1:<!-- Versions names can be separated by whitespace, comma (,) and/or semi-colon (;) --> Choose a version for lib2: Reload with the above selected Versions
JavaScript
// Fill manage placeholders with Radio Inputs.bundle; // Make sure lib2 dev version assets are available.// If not, it will automatically disable the Radio Input and remove// the defaultVersion flag.bundle ; { // Read in the URL which Libraries Versions are requested. var url = windowlocationhref; // https://github.com/medialize/URI.js var urlParts = URI; var queryStringParts = URI; // Get the Libraries Versions assets list and select the Radio Inputs, // so that the user sees which Versions will be loaded. var list = bundle; // Finally include the page script, now that lib1 and lib2 dependencies // are available. list; // https://github.com/ghybs/load-js-css loadJsCss;} document;
License
Manage Libs Versions library is distributed under the ISC License.