I am writing an application at the moment that uses jquery. It fits in to an existing application that uses prototype so obviously I cant use the dollar sign straight away.
I have been using noconflict to get around this but couldnt I just wrap my whole script inside a closure passing in jquery as in:
(function( $ ){
})( jQuery );
This seems to work but I am wondering if there are any consequences to this?
That should work fine, since your passing jQuery into your closure as the jQuery object itself.
The noConflict should still be specified though – otherwise the jQuery object could take control of the dollar sign. Calling noConflict passes the dollar sign back to anything that is already using it.
The documentation suggests this too: