---
title: "jQuery's no-conflict mode: yet another reason why it's the best"
date: 2007-07-03
canonical: https://michaelshadle.com/2007/07/03/jquerys-no-conflict-mode-yet-another-reason-why-its-the-best
---

# jQuery's no-conflict mode: yet another reason why it's the best

It took me a bit to find out why jQuery (now bundled with WordPress) was not working as I expected inside of the WP admin area. The script was being called, but my code like $("#foo") was not working. I really had no clue where to begin, since it still has all those old JS libraries/frameworks being called as well. It was due to Prototype being packaged with it and conflicting with the "$" shortcut.

Long story short, jQuery already planned for library conflicts and has a quick solution. The no-conflict mode allows you to define your own shortcut, and of course it works like a charm.

It's easy to do - just put this line in your code somewhere:

```php
var J = jQuery.noConflict();
```

Now $("#foo") will be J("#foo") and it will not conflict with any other libraries that may be installed. I hope WP gets rid of all the other stuff and goes with pure jQuery and plugins soon enough though :)
