Side navigation
#5635 closed enhancement (wontfix)
Opened December 10, 2009 06:59PM UTC
Closed November 19, 2010 08:21AM UTC
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!