Lightweight and very simple JS require
<script src="pathtojs/require.js"></script>require.init({
'alias1': 'path/file1.js',
'alias2': 'path/file2.js',
'alias3': 'path/file3.js',
'alias4': 'path/file4.js',
});require.get('alias1').done(function() {
// Script loaded, we can use it
})
.fail(function() {
});You can use then() as well and enjoy its chaining power:
require.get('alias1').then(function() {
// Script loaded, we can use it
return $aValue;
})
.then(function($aValue) {
// You can use the value computed in the previous then statement
});- JQuery