jQuery noConflict() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Core

Definition

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.

Syntax

Start with these common calls. Keep them short and readable.

jQuery
// 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
});
CallWhat it does
removeAlltrue also releases global jQuery
Return valueThe jQuery object (save as an alias)
Call timingAfter jQuery loads, before other-lib $ code

Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.

Parameters

ParameterDescription
Step 1Load the other library that needs $ (if any), then load jQuery.
Step 2Call jQuery.noConflict() so global $ returns to the other library.
Step 3Use jQuery(...), a saved alias, ready’s $ argument, or an IIFE.

Return Value

Return ValueDescription
jQuery objectMost setters and traversing helpers return the jQuery collection so you can chain more methods.

jQuery Examples

Example 1 — Restore $, Use jQuery

Official pattern: give $ back, then call jQuery by name.

jQuery
jQuery.noConflict();

// jQuery code
jQuery("div p").hide();

// Other library can use $ again
// $("content")…
Try It Yourself

How It Works

  1. Release. noConflict() restores the previous global $.
  2. Keep jQuery. The jQuery global name still works.
  3. Select. Call methods as 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
Try It Yourself

How It Works

  1. Release. Global $ is no longer jQuery.
  2. Ready. jQuery passes itself into the callback as $.
  3. Local. Inside that function, $ is safe and private.

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
Try It Yourself

How It Works

  1. Pass. The IIFE receives jQuery as the parameter $.
  2. Scope. Inside the function, $ always means jQuery.
  3. Ready. Nested $(function () { … }) still works.

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().

Next: Selectors

Learn how jQuery reports errors thrown inside ready handlers.

Selectors tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful