Created
January 18, 2017 15:36
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
ministack.push(function () | |
{ | |
require(['anyMOD'], function(anyMOD){ | |
}); | |
}); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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](); | |
} | |
} | |
} | |
}; | |
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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