Created
March 3, 2014 05:30
-
-
Save ssddi456/9318954 to your computer and use it in GitHub Desktop.
requirejs preload with fis's namespaced package
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
define("common:lib/base.js",function( | |
require, exports, module | |
){ | |
exports.sayhi = function( some_one) { | |
console.log( 'hello, ' + some_one ); | |
} | |
}); | |
define('widget:tip',function( | |
require, exports, module | |
){ | |
var base = require('common:lib/base.js'); | |
exports.tip = function( some_one, tip_msg ) { | |
base.sayhi( some_one + ' ' + tip_msg ); | |
} | |
}); |
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
// pre load module | |
define('fis_loaded',[ | |
'common' | |
],function( ){ | |
// now all fis packed module can be use | |
return {}; | |
}); | |
require([ | |
'fis_loaded' | |
],function( | |
){ | |
// use your fis packed module here | |
require(["widget:tip"],function( | |
tip | |
){ | |
tip.tip( 'joy', 'be quite' ); | |
}) | |
}) |
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
<html> | |
<script> | |
var require = { | |
paths : { | |
'common' : 'fis_package', | |
'main' : 'fis_preload_and_use' | |
}, | |
deps : ['main'] | |
} | |
</script> | |
<script charset="utf-8" | |
src="require.js"></script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment