Skip to content

Instantly share code, notes, and snippets.

@DanyelMorales
Created January 18, 2017 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DanyelMorales/f49a88357d9627d6bb83d9354409438c to your computer and use it in GitHub Desktop.
Save DanyelMorales/f49a88357d9627d6bb83d9354409438c to your computer and use it in GitHub Desktop.
Push a module to a stack before RequireJS is loaded, then when RequireJS get loaded the modules will be invoked.
<script>
ministack.push(function ()
{
require(['anyMOD'], function(anyMOD){
});
});
</script>
(function () {
if (typeof window.ministack !== 'undefined') {
return window.ministack;
}
window.ministack = {
stack: []
, push: function (callback) {
this.stack.push(callback);
}
, pop: function () {
return this.stack.pop();
}
, amd: function () {
if (typeof define !== 'undefined') {
for (var i in this.stack) {
this.stack[i]();
}
}
}
};
}());
if (typeof ministack !== 'undefined')
{
ministack.amd();
}
require.config({...});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment