Skip to content

Instantly share code, notes, and snippets.

@bencooling
Created November 3, 2014 04:33
Show Gist options
  • Save bencooling/f53012b8619a4560e223 to your computer and use it in GitHub Desktop.
Save bencooling/f53012b8619a4560e223 to your computer and use it in GitHub Desktop.
requirejs implementation that won't override global jQuery
'use strict';
/*
|--------------------------------------------------------------------------
| Requirejs configuration
|--------------------------------------------------------------------------
|
| This file is used by both the browser & command line optomisation
| tool (see gruntfile.js)
|
| baseUrl
| data-main script (this file) is in the assets directory, while all
| external library scripts are within js subdirectory
|
| paths
| set paths for external libraries and main which is not in directory above baseUrl
|
| shim
| Non AMD jquery plugins need to be explicitly set as a jquery dependency
|
| private jquery wont clobber global jQuery variable
|
*/
require.config({
baseUrl: './../',
paths: {
'jquery' : 'assets/vendor/jquery/dist/jquery'
}
});
define('jquery-private', ['jquery'], function (jq) {
return jq.noConflict( true );
});
require(['jquery-private'], function($){
console.log( '$.fn.jquery ', $.fn.jquery );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment