Skip to content

.noConflict() compliance: only reference $, not jQuery, inside the closure #26

merged 1 commit into from Jul 18, 2012

2 participants


According to the jQuery coding standards (, you shouldn't reference 'jQuery' inside the closure, only '$':

.noConflict() compliance

Wrap plugins in a closure that passes jQuery in as a parameter. Inside the closure, only reference jQuery through the parameter variable.

(function( $ ) {
// inside here only reference $, not jQuery
}( jQuery ) );


Can you explain the reasoning behind ? Why using jQuery is an issue ?


Couple of examples for why you need noConflict() mode:

1) Not everyone can override $ with jQuery in their web applications. For example, people who have a legacy Prototype dependency, but want to use some jQuery features. So some people can only rely on jQuery('.item') instead of $('.item').

2) If you are writing a third-party library that uses jQuery, but the site that may be adding your library also might have their own jQuery implementation. So you need $ and MyLib.$ to coexist.

@jeromeetienne jeromeetienne merged commit 2d05056 into jeromeetienne:master Jul 18, 2012

my bad, i first read the patch on my phone. my bad :)

merged, thanks for contributing!


No problem, thanks for the plugin!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.