How it works

Drupal loads its own jQuery library

Before any of our javascript loads, Drupal has already loaded its default jQuery library.

Any other javascript runs

It's okay for other javascript to run at this stage, just so long as the next three steps all happen in direct sequence:

Load the new jQuery library

When jQuery 1.3 loads, it copies any pre-existing definitions of jQuery() and $() to 'backup' variables _jQuery and _$, before defining its own replacement versions.

The global jQuery() and $() now refer to jQuery 1.3

Load any plug-ins which require jQuery 1.3

jQuery plug-ins attach themselves as methods to the global jQuery object. Because the global jQuery is (for the moment) jQuery 1.3, this means the plug-in will attach itself as a method available to jQuery 1.3 (and not available to the original jQuery).

Run jquery-noconflict.js

var jQuery13 = jQuery; copies the current definition of jQuery to a non-conflicting name.

jQuery.noConflict(true); tells jQuery to restore the global definitions of jQuery() and $() to whatever they were before jQuery 1.3 loaded.

This means that they once again refer to the original core jQuery library supplied with Drupal, while our new jQuery13 object remains in existence, along with the plugins that attached themselves to it.

Use the plugin via the jQuery13 object

Because the global names have already been tidied up, it doesn't matter when this code runs.