Hi all,
I actually posted this in bug <a href="http://jquery.com/dev/bugs/bug/137/" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">#137 - Prototype Support Plugin</a>, but then I realized it might be more appropriate on the mailing list, since I'm looking for feedback on this idea.
Is the main issue here making jQuery compatible with Prototype, or just
making it compatible with all other libraries (now including mootools
et al) which use '$' as a shortcut in the global namespace?
I think it's worth pointing out that jquery.js is written well enough that it doesn't <i>have</i>
to map the jQuery function to $, except as a convenience to users, and
for backwards-compatibility with existing plugins.
There is (presumably) no future-compatible way to consistently merge
the output of jQuery and Prototype's '$' functions together -- and this
would remain ugly and messy, in any case. My suggestion would be
providing the option to map jQuery to a different shortcut (like $J,
for example), and not override prototype's $, if this is what the user would prefer.
There are a number of ways this could be implemented:
The script could check for such a hash, and if present, map jQuery to the specified shortcut instead of $.
This is an example implementation (which works in firefox at least):
...which would fall back to the same effect as <tt>var $ = jQuery;</tt> .