Skip to content

Instantly share code, notes, and snippets.

@masahirompp masahirompp/module1.js
Last active Aug 29, 2015

Embed
What would you like to do?
AMD/namespace template
(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';
// ここに処理を書く
}));
<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>
<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
You can’t perform that action at this time.