> > From: Michael Geary
> >
> > (function($) {
> > // plugin code here
> > })(jQuery);
> From: Sam Collett
>
> I've seen that used before, but can it have memory leak
> or other issues?
Sorry about the very slow reply, Sam.
That's a good point. The use of the closure could result in memory leaks
depending on what the rest of the code does. They should be fixable -
closures in and of themselves don't cause leaks, but they can result in
circular references to DOM objects in IE. It would be good to test this and
make sure it doesn't cause a leak.
> Does it work on all modern browsers (and not so
> modern - IE 5), included those on PDA's etc (not
> that jQuery supports portable devices).
Yes, closures are standard JavaScript and work in every version of
JavaScript since 1.1 or 1.2, I forget which.
> What happens if 'jQuery' is undefined?
Then you'll get an error when it tries to call the closure function with the
jQuery argument. Of course, the same thing would occur if you coded a plugin
the traditional way:
jQuery.fn.foobar = function() {};
-Mike
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/