jQuery.noConflict([removeAll]) (since 1.0) gives the global $ name back to whatever owned it before jQuery loaded. jQuery itself stays available as jQuery unless you pass true. The method returns the jQuery object so you can keep an alias.
Remember
// Give $ back to the other library
jQuery.noConflict();
// Still use jQuery by full name
jQuery("div p").hide();
// Or keep a private alias
var $jq = jQuery.noConflict();
$jq("div p").hide();
// Or use $ safely inside ready / an IIFE
jQuery(function ($) {
// $ is jQuery here
});
Need
Use
Free global $
jQuery.noConflict()
Keep a short alias
var j = jQuery.noConflict()
Use $ inside ready
jQuery(function ($) { … })
IIFE scope
(function ($) { … })(jQuery)
Free $ and jQuery
jQuery.noConflict(true) ⚠
Approach
How to Use noConflict()
Load order matters. Free $, then keep a clear way to call jQuery.
Load the other library that needs $ (if any), then load jQuery.
Call jQuery.noConflict() so global $ returns to the other library.
Use jQuery(...), a saved alias, ready’s $ argument, or an IIFE.
Only pass true when you must also remove the global jQuery name.
Avoid loading two jQuery versions unless you have a rare migration need.
Paragraph hidden with jQuery(...)
Global $ belongs to the other library again
How It Works
Release.noConflict() restores the previous global $.
Keep jQuery. The jQuery global name still works.
Select. Call methods as jQuery(...).
Share. Other code can use $ without fighting jQuery.
Example 2 — Safe $ Inside Ready
Official pattern: after noConflict, the ready callback receives jQuery as $.
jQuery
jQuery.noConflict();
jQuery(document).ready(function ($) {
// $ is jQuery here
$("p").text("Styled inside ready with local $");
});
// Outside, global $ is the other library
Styled inside ready with local $
Outside ready, global $ is still the other library
How It Works
Release. Global $ is no longer jQuery.
Ready. jQuery passes itself into the callback as $.
Local. Inside that function, $ is safe and private.
Outside. Code after ready still sees the other library’s $.
Example 3 — IIFE Alias
Official pattern: wrap jQuery code in (function ($) { … })(jQuery).
jQuery
jQuery.noConflict();
(function ($) {
$(function () {
$("li").text(function (i, t) {
return t + " ✓";
});
});
})(jQuery);
// Other code using $ as the other library
j === jQuery → true
Paragraph hidden with j(...)
Global $ is the other library
How It Works
Capture.noConflict() returns the jQuery function.
Alias. Store it in j (or any name you like).
Call. Use j(...) instead of $(...).
Free $. The global dollar sign is available elsewhere.
Example 5 — noConflict(true)
Official pattern: move jQuery into your own namespace and clear both globals.
jQuery
var dom = {};
dom.query = jQuery.noConflict(true);
// New reference
dom.query("div p").hide();
// window.$ and window.jQuery are restored / cleared
// Plugins that need global jQuery may break
typeof window.jQuery → undefined (or prior owner)
dom.query still works
Use removeAll carefully
How It Works
Capture first. Save the return value before globals disappear.
removeAll.true releases both $ and jQuery.
Namespace. Call methods through dom.query.
Caution. Many plugins look for window.jQuery — avoid this unless required.
Edge Cases & Pitfalls
Check these before mixing jQuery with another $ library.
order
Load order matters
jQuery can only restore a previous $ if that owner was already on the page when jQuery loaded.
plugins
noConflict(true) breaks many plugins
Plugins often expect window.jQuery. Capture a reference, or avoid removeAll.
two
Two jQuery versions are a last resort
Official docs show it for edge cases. Prefer a single version for size and sanity.
$
Global $ is gone after plain noConflict
Use jQuery, a saved alias, ready’s $, or an IIFE — not bare $ in the global scope.
Compatibility
Browser Support
jQuery.noConflict() has been part of jQuery since 1.0. The optional removeAll flag releases both $ and jQuery from the global scope.
✓ Stable · jQuery 1.0+
jQuery.noConflict()
Works in every browser that runs your loaded jQuery version. Behavior depends on which globals existed before jQuery loaded.
100%Core API
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
noConflictUniversal
Bottom line: Safe for everyday multi-library pages. Prefer plain noConflict() plus jQuery(function($){}) or a saved alias; use true only when necessary.
Analysis
Performance Notes
Approach
Cost
Best for
Plain noConflict()
Negligible
Sharing $ with another lib
Ready / IIFE alias
Negligible
Keeping $ locally for jQuery
Two jQuery builds
Expensive (size)
Avoid — one version is enough
noConflict itself is cheap. The real cost is loading extra libraries or duplicate jQuery builds — keep the page to one jQuery when you can.
Remember
Key Takeaways
Role: give global $ back so another library can use it.
Keep jQuery: use jQuery, a saved alias, ready’s $, or an IIFE.
Return value: always capture it if you pass true.
One build: avoid loading two jQuery versions on one page.
One line:noConflict() frees $ for other libraries — keep calling jQuery via jQuery or a private alias.
Frequently Asked Questions
jQuery.noConflict() returns control of the global $ variable to whatever owned it before jQuery loaded. jQuery remains available as the global jQuery identifier. Optionally pass true (removeAll) to also release the jQuery global name. Available since jQuery 1.0.
After a plain noConflict() call, the global $ is no longer jQuery. You can still write jQuery("div"), assign var $jq = jQuery.noConflict(), or use the ready alias: jQuery(function($){ /* $ is jQuery here */ }).
Passing true removes both $ and jQuery from the global scope (restoring prior owners). The method returns the jQuery object so you can keep a local reference: var jq = jQuery.noConflict(true). Rarely needed — and it can break plugins that expect window.jQuery.
Call it after jQuery loads and before code that needs the other library’s $. Typical order: load other lib, load jQuery, call jQuery.noConflict(), then write jQuery-based code with jQuery or a saved alias.
No. Prefer one jQuery version. If you must, load both scripts, then call noConflict(true) on the second version to restore the first as the global jQuery/$.
Use jQuery(function($){ ... }), wrap code in (function($){ ... })(jQuery), or save the return value: var $jq = jQuery.noConflict().