Skip to content

Instantly share code, notes, and snippets.

@simonewebdesign
Created July 9, 2013 09:02
Show Gist options
  • Save simonewebdesign/5955841 to your computer and use it in GitHub Desktop.
Save simonewebdesign/5955841 to your computer and use it in GitHub Desktop.
How to use RequireJS with NivoSlider
<script src="/scripts/require.js"></script>
<script src="/scripts/require.config.js"></script>
<script>
require(['slider'], function ($) {
console.log($); // jquery with slider
//console.log($('.slide').nivoSlider({}));
});
</script>
requirejs.config({
// If set to true, an error will be thrown if a script loads
// that does not call define() or have a shim exports string
// value that can be checked. See Catching load failures in
// IE for more information. RequireJS enforceDefine
enforceDefine: true,
// path to libraries
baseUrl: '/scripts/',
// cache bust! PLEASE REMOVE in production environment
urlArgs: 'bust=' + (new Date()).getTime(),
paths: {
// from the official CDN
'jquery': 'http://code.jquery.com/jquery-1.10.1.min',
'slider': 'nivo-slider/jquery.nivo.slider'
},
shim: {
'slider': {
deps: ['jquery'],
exports: '$'
},
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment