Created
November 16, 2011 19:25
-
-
Save Zoramite/1371054 to your computer and use it in GitHub Desktop.
jQuery plugin definition with optional support for RequireJS
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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<title>Test Execute Order</title> | |
</head> | |
<body> | |
<script src="//requirejs.org/docs/release/1.0.1/minified/require.js"></script> | |
<script> | |
require.config({ | |
paths: { | |
'jquery': '//ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min' | |
} | |
}); | |
</script> | |
<script> | |
require(['scripts/test1'], function(){ | |
console.log('In index1.') | |
}); | |
</script> | |
</body> |
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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<title>Test Execute Order</title> | |
</head> | |
<body> | |
<script src="//requirejs.org/docs/release/1.0.1/minified/require.js"></script> | |
<script> | |
require.config({ | |
paths: { | |
'jquery': '//ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min' | |
} | |
}); | |
</script> | |
<script> | |
require(['scripts/test2'], function(){ | |
console.log('In index2.') | |
}); | |
</script> | |
</body> |
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 exports === 'object') { | |
// Node/CommonJS | |
factory(); | |
} else if (typeof define === 'function' && define.amd) { | |
// AMD | |
define('test', [], factory); | |
} else { | |
// Browser globals | |
factory(); | |
} | |
}(function() { | |
console.log('In test1.'); | |
})); |
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 exports === 'object') { | |
// Node/CommonJS | |
factory(require('jquery')); | |
} else if (typeof define === 'function' && define.amd) { | |
// AMD | |
define('test', [ 'jquery' ], factory); | |
} else { | |
// Browser globals | |
factory(jQuery); | |
} | |
}(function($) { | |
console.log('In test2.') | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment