- From: Aryeh Gregor <Simetrical+w3c@gmail.com>
- Date: Wed, 28 Oct 2009 19:47:37 -0400
- To: Jonas Sicking <jonas@sicking.cc>
- Cc: Tony Ross <tross@microsoft.com>, "public-html@w3.org" <public-html@w3.org>
On Wed, Oct 28, 2009 at 5:14 PM, Jonas Sicking <jonas@sicking.cc> 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? I think his point is that typically, JavaScript libraries only expose a single global variable, and implement everything as methods and member variables of that. So even if it turns out two people independently made libraries that create a "myLibrary" global object, you can still do <script src=mylibrary1.js></script> <script>myLibrary1 = myLibrary;</script> <script src=mylibrary2.js></script> Or something like that. The more general point here is that with JS, you typically have access to the source code of the library in some form, at worst somewhat obfuscated, and you can always rename things yourself if it causes a problem. If it's a binary program like MS Word or something that's interpreting the HTML, on the other hand, then if a naming conflict arises, you're stuck. However, I don't think the kind of workaround Tony is referring to (if I understand him right) is ever needed in practice for JS libraries, even if it's theoretically possible. Namespacing really seems to me like a solution to a wholly hypothetical problem.
Received on Wednesday, 28 October 2009 23:48:10 UTC