Skip to content

Instantly share code, notes, and snippets.

@wwsun
Created May 11, 2015 12:49
Show Gist options
  • Save wwsun/c9114465742095e0759f to your computer and use it in GitHub Desktop.
Save wwsun/c9114465742095e0759f to your computer and use it in GitHub Desktop.
AMD Demo
define([], function() {
return 'Example file';
});
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<title>AMD example</title>
</head>
<body>
<script src="require.js"></script>
<script>
require({
'paths': {
'example': './example'
}
}, ['example'], function(example) {
alert('Hello from "' + example + '"');
});
</script>
</body>
</html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<title>AMD example</title>
</head>
<body>
<script src="require.js"></script>
<script>
require({
'paths': {
'jquery': 'http://code.jquery.com/jquery-2.1.3'
}
}, ['jquery'], function($) {
alert('jQuery version: ' + $.fn.jquery);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment