Helpers - mitzerh/modulr-js GitHub Wiki
The version your page is using.
Note that in the case the the page tries to load multiple Modulr instances, the first loaded instance is used, the rest are ignored.
You can use this to keep track of what files are loaded for which packages. You can simply run this function on your browser console
.
This can also help during Optimization to include specific files in your aggregation, the files found in other different paths of shim files you host.
You can use this to execute Modulr ready
state prior to the DOM ready event. Useful if you want to execute inline, at the bottom of your <body>
tag.
In case-specific scenarios where you need to load a package not defined in your Instance's config.packages
, you can use this function.
// example
Instance.loadPackage({
"Another.Instance": "/path/to/instance/bootstrap.js"
}, function(){
Instance.require(["Another.Instance:modules/foo"], function(){
console.log("Another.Instance is available!");
});
});
When you need to append a query parameter to all scripts loaded by Modulr. By default, when defined, it will use "v" query parameter. You can use in combination with @cacheParam
to use custom parameter name.
Returns the value from setting it up @ setGlobalCacheParam()
.
Sets up custom cache conditions for particular js files. This is ideal for situations where you need custom cache busting string for other files, bypassing whatever was set on Modulr.setGlobalCacheParam()
// example
// set browser cache busting param for all files with ?v=1.5-rc1
Modulr.setGlobalCacheParam('1.5-rc1');
Modulr.setGlobalCacheCond([
// set cache param for this file to ?c_str=xxxxxx
{
regex: /my-custom-script.js/,
param: 'c_str',
noStore: true
}
]);
The value of the xxxxxx
in the example is a generated timestamp using your browser's date.
When you need Modulr to execute after a certain condition. By default Modulr will execute on document ready, this is useful if you have scripts that needed to run first, post-document ready.
// example
Modulr.setExecuteListener(function(execute){
window.addEventListener('load', function(){
execute();
}, false);
});