Ticket #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: | ||
| Blocking: | Blocked by: |
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
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
