> I've actually ellaborated on the idea and come up with my own version: > ;if(jQuery) (function($){ > ... > > })(jQuery); > > ...which: > - encloses local vars > - silently ignores the code if jQuery is unavailable > - avoid colisions when files are merged (; at the start)
That will fail if jQuery isn't included, you can do either: if( window.jQuery ) or if( typeof jQuery != 'undefined' ) Note that the (function($){ ... })(jQuery); approach is 6 bytes shorter than (function(){ var $ = jQuery; })(); It also looks cooler ;) -- Ariel Flesler http://flesler.blogspot.com