Bug Tracker

Modify

Ticket #5635 (closed enhancement: wontfix)

Opened 3 years ago

Last modified 2 years ago

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

comment:1 Changed 3 years ago by dmethvin

  • Component changed from unfiled to core

comment:2 Changed 2 years ago by snover

  • Status changed from new to closed
  • Resolution set to wontfix

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

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.