After looking at the code it seems quite straight-forward. Someone
correct me if I've got the wrong end of the stick.

Summary: The first version you include will get reinstated, the second
version getting blown away.

How it works: When you include jQuery, it makes a copy of the window.$
and window.jQuery variables and puts them into _$ and _jQuery
(variables inside jQuery itself) respectively. So if there's already a
copy of jQuery included on the page (call it v1) and you go include
your second copy (call it v2), v1 will get 'backed up' into the _$ and
_jQuery variables inside v2 and the second copy you include will go
into window.$ and window.jQuery. At this point, if you use the $
function or the jQuery object, you'll be using v2. When you call
jQuery.noConflict(true), it will run against v2 because that's what's
in window.jQuery and it'll take the variables in _$ and _jQuery (which
are v1), put them back into window.$ and window.jQuery, and return you
a copy of v2 for you to put into a variable (called jQv2 for example).

At this point, window.$ and window.jQuery will be v1 and jQv2 will be
v2. So if you want to use v1, you carry on using $(...) or
jQuery.whatever(...) and if you want to use v2, you use
jQv2('#someId') or jQv2.whatever(...).

Hope this makes sense.

George.

On Oct 4, 12:27 am, "Glen Lipka" <[EMAIL PROTECTED]> wrote:
> We are making a jQuery+stuff script that will go on lots of random pages
> with unknown libraries.
> Some of those pages will have jQuery. (Various versions)
>
> If I am including our script last; what is the best way to make sure our
> script doesn't interfere with any of the existing page, including old
> versions of jQuery.
>
> Solution #1: We renamed jQuery in our script everywhere to be veryjQuery.
> Solution #2: ???
>
> Note: Solution #1 solved the problem, but feels invasive.  Is there a
> noconflict() way to do this?
>
> Glen

Reply via email to