Last Updated: February 25, 2016
· flurin

Simplest requirejs jQuery.noConflict() wrapper

Because we often want to run jQuery in noConflict mode we have a simple wrapper module that returns the noConflict jQuery object.

define(["jquery-1.7"], function(){
  return jQuery.noConflict(true);

In the requirejs config looks like this:

  paths: {
    "jquery-1.7": ["//", "vendor/jquery-1.7.2.min"], // Don't use this one as a direct dependency! Use require-jquery
    "require-jquery" : "src/require-jquery"

And we use the require-jquery module as a dependency wherever we use jQuery.