Bug Tracker

Opened 10 years ago

Closed 9 years ago

#5635 closed enhancement (wontfix)

Check for typeof jQuery before overwriting the namespace

Reported by: jpgrace Owned by:
Priority: major Milestone: 1.4
Component: core Version: 1.4a1
Keywords: Cc:
Blocked by: Blocking:

Description

I work with some very large companies that have jQuery includes all over the place. This causes a problem with namespacing and plugins. Currently the solution is to do this:

use jQuery from Google (presumably it will be cached on users browser)

if (typeof(jQuery) == "undefined") {

document.write('<sc'+'ript type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"><\/script>');

} if not Google, then here if (typeof(jQuery) == "undefined") {

document.write('<sc'+'ript type="text/javascript" src="/lib/js/jquery.js"><\/script>');

}

I was wondering if you would consider wrapping jQuery in a test to see if it was already defined. This would eliminate namespacing collisions. It might encourage bad behavior (placing jQuery at the top of the page to precede subsequent ignored includes), but it would also be more compatible.

Thanks, keep up the great work!

Change History (2)

comment:1 Changed 9 years ago by dmethvin

Component: unfiledcore

comment:2 Changed 9 years ago by snover

Resolution: wontfix
Status: newclosed

There is already a way to avoid conflicts, jQuery.noConflict.

Note: See TracTickets for help on using tickets.