Last active
August 29, 2015 14:15
-
-
Save masahirompp/5189dccc2c931e272486 to your computer and use it in GitHub Desktop.
AMD/namespace template
This file contains hidden or 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(factory){ | |
if(typeof define === 'function' && define.amd){ | |
define(['underscore', 'other1'], factory.bind(this)); | |
}else{ | |
this.module1 = factory.call(this, this._, this.other1); | |
} | |
}.call(this, function(_, other1){ | |
'use strict'; | |
// ここに処理を書く | |
})); |
This file contains hidden or 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> | |
<head></head> | |
<body> | |
<script src="js/lib/underscore.js"></script> | |
<script src="js/other1.js"></script> | |
<script src="js/module1.js"></script> | |
<script> | |
window.module1.someMethod(); | |
</script> | |
</body> | |
</html> |
This file contains hidden or 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> | |
<head></head> | |
<body> | |
<script src="js/lib/require.js"></script> | |
<script> | |
require.config({ | |
paths: { | |
underscore: 'js/lib/underscore' | |
} | |
}); | |
require('js/module1'); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment