[Greasemonkey] Wrapping scripts in a self calling function
Rod McGuire
mcguire at telerama.com
Sun Sep 24 02:43:40 EDT 2006
Quoting Gary Tyler <pile0nades at gmail.com>:
> I've seen gm scripts wrap their code in something like this:
>
> (function() {
> // code
> })();
>
> Does this do anything different than not using this at all? Just wondering.
In the old days when greasemonkey actually injected a script into a userpage,
there were the potential problems of "name collisions" and "name stealing". So
that sort of wrapping was used to set up a private name space.
In the current Greasemonkey, scripts *do* run in a private namespace, so
wrapping is not needed.
More information about the Greasemonkey
mailing list