Skip to content

Instantly share code, notes, and snippets.

@momolog
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save momolog/3d2da1cdffd8373fd99f to your computer and use it in GitHub Desktop.
Save momolog/3d2da1cdffd8373fd99f to your computer and use it in GitHub Desktop.
<html>
<head>
<script data-main="index" src="require.js"></script>
</head>
<body></body>
</html>
require(['mylib.js'], function(mylib){
mylib.myfunction();
});
// version 1
require.config({
paths: {
'jquery': 'jquery-1.11.2.min',
'isotope': 'isotope.pkgd.min',
'imagesloaded': 'imagesloaded.pkgd.min',
'packery-mode': 'packery-mode.pkgd'
},
});
define(['jquery', 'isotope', 'imagesloaded', 'packery-mode'], function(jquery, Isotope, imagesLoaded){
var mylib = {
myFunction(){
alert('hello');
}
};
return mylib;
}
// version 2
require.config({
paths: {
'jquery': 'jquery-1.11.2.min',
'isotope': 'isotope.pkgd.min',
'imagesloaded': 'imagesloaded.pkgd.min',
'packery-mode': 'packery-mode.pkgd'
},
});
define(['jquery', 'isotope', 'imagesloaded'], function(jquery, Isotope, imagesLoaded, ){
require(['packery-mode'], function(packeryMode){
var mylib = {
myFunction(){
alert('hello');
}
}
return mylib;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment