W3C home > Mailing lists > Public > public-html@w3.org > October 2009

Re: ISSUE-41/ACTION-97 decentralized-extensibility

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Wed, 28 Oct 2009 20:58:28 -0500
Message-ID: <dd0fbad0910281858k76c649b5vd14ea1863e6e53fd@mail.gmail.com>
To: Tony Ross <tross@microsoft.com>
Cc: Jonas Sicking <jonas@sicking.cc>, "public-html@w3.org" <public-html@w3.org>
On Wed, Oct 28, 2009 at 8:07 PM, Tony Ross <tross@microsoft.com> wrote:
> On Wednesday, October 28, 2009 at 2:15 PM, Jonas Sicking wrote:
>> On Tue, Oct 27, 2009 at 6:07 PM, Tony Ross <tross@microsoft.com> wrote:
>> > The nature of script and these libraries provides consumers with an
>> > adequate means of resolving object name conflicts should they arise.
>> > The global variable for these libraries can typically be reassigned to
>> > another variable without impacting the behavior of the library itself.
>> > Thus should two names ever conflict, a page author can just rename the
>> > first before the second library loads.
>>
>> Hmm.. Not quite sure I follow what you're saying. Do you have any
>> examples?
>
> Link from the homepage of jQuery's website which illustrates some examples (though mostly focused on jQuery's use of '$'):
> http://docs.jquery.com/Using_jQuery_with_Other_Libraries

Interestingly, jQuery purposely invaded that name-space.  The use of $
was already widespread as a short form of getElementByID, and I
Prototype was already using it to upgrade element nodes as well.
jQuery overlapped itself on that name, and thus deliberately made it
easy to swap it out if necessary (you can always use jQuery() instead
of $(), and it is careful to save the old definition, if any, of $ so
that you can unclobber it if you want).  jQuery docs also stress an
idiom for allowing library authors to use the short form without
conflicts.

Many libraries do build on the single-global-object method of reducing
namespace pollution, but I don't think many were as careful as jQuery.
 (They may be more careful now, I dunno.)

~TJ
Received on Thursday, 29 October 2009 01:59:15 UTC

This archive was generated by hypermail 2.3.1 : Monday, 29 September 2014 09:39:09 UTC