Reputation: 273582
I am working on a server-side framework.
Here and there I have been adding hand-crafted javascript to do things on the client side. However this is becoming more and more painful and from what I heard I think jQuery can be of help.
The issue is that as this is essentially server side stuff, I don't want to obligate my users (assuming there will be any :) to use jQuery.
So the question is, how good is jQuery at coexisting with other popular javascript libraries? Will it hijack global names and events for its own purposes or is it a relatively respectful & coexisting dude.
Upvotes: 1
Views: 254
Reputation: 4012
jQuery has two global identifiers: jQuery and $
You can change that to one identifier by using jQuery.noConflict(), and then the only global is jQuery.
Upvotes: 1
Reputation: 511
The generally accepted principal with jQuery is scope your access to it within an anonymous function. This prevents namespace pollution. The pattern looks like:
// anonymous function that takes the jquery $ object (aka window.jQuery)
(function($) {
$(document).ready(function() {
// jQuery code here, call functions, etc
});
})(jQuery.noConflict()); // removes $ from window scope, returns the jQuery object
See more: http://docs.jquery.com/Core/jQuery.noConflict
Upvotes: 1
Reputation: 17554
jquery has a noconflict option which helps with using it with other libraries.
You can also compare how much it pollutes the global namespace against other libraries here
I'm also not sure what you're actually asking, as you discuss adding javascript client side enhancements but then go on to say that it will mostly be 'server side stuff'. Which is it? Mostly client or mostly server?
Upvotes: 6