Friday, December 11, 2009

Using jQuery with Other Libraries

The jQuery library, and virtually all of its plugins are constrained within the jQuery namespace. As a general rule, "global" objects are stored inside the jQuery namespace as well, so you shouldn't get a clash between jQuery and any other library (like Prototype, MooTools, or YUI).

That said, there is one caveat: By default, jQuery uses "$" as a shortcut for "jQuery".

However, you can override that default by calling jQuery.noConflict() at any point after jQuery and the other library have both loaded.

When you use jQuery with other libraries, jQuery still is functional.
You can use jQuery directly

  // Use jQuery via jQuery(...)
  jQuery(document).ready(function(){
    jQuery("div").hide();
  });


or reassign jQuery to another shortcut

  var $j = jQuery;
  // Use jQuery via $j(...)
  $j(document).ready(function(){
    $j("div").hide();
  });


For more detail, please see http://docs.jquery.com/Using_jQuery_with_Other_Libraries.

No comments: