[tw] Re: JavaScript common to multiple tiddlers

2009-10-18 Thread FND

 Does this mean I shouldn't be using version.extensions. at all?

I consider it good practice to use that namespace for plugins' 
functionality (public methods anyway).

 Thanks Eric for going through the scenarios. The probability is so low
 that a plugins would appear twice, and exponentially lower that it
 would actually have any more effect than the performance overhead of
 loading twice, that it does seem unnecessary.

Also, one could argue that problems resulting from a plugin being loaded 
twice - while tricky to identify - should not be hidden from users; 
obscuring errors in the document could backfire in the long term.


-- F.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TiddlyWiki group.
To post to this group, send email to tiddlywiki@googlegroups.com
To unsubscribe from this group, send email to 
tiddlywiki+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en
-~--~~~~--~~--~--~---



[tw] Re: JavaScript common to multiple tiddlers

2009-10-16 Thread Michael Mahemoff

On Thu, Oct 15, 2009 at 8:54 PM, FND f...@gmx.net wrote:

 why is it good practice for plugins to check if they've already been
 loaded? (if version.extensions.) { } at the top of most plugins)

 Cargo-culting.
 This doesn't actually solve any useful purpose AFAICT. I'm not sure
 where it originates, but I don't include those bits in my plugins
 anymore (though I haven't gotten around to removing it from all existing
 plugins yet).


Funny as I do it all the time, and I don't think I'm the only one.

Does this mean I shouldn't be using version.extensions. at all?

Thanks Eric for going through the scenarios. The probability is so low
that a plugins would appear twice, and exponentially lower that it
would actually have any more effect than the performance overhead of
loading twice, that it does seem unnecessary.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TiddlyWiki group.
To post to this group, send email to tiddlywiki@googlegroups.com
To unsubscribe from this group, send email to 
tiddlywiki+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en
-~--~~~~--~~--~--~---



[tw] Re: JavaScript common to multiple tiddlers

2009-10-15 Thread FND

 I have several HTML pages I want to import into a TiddlyWiki and each
 references the same external .JS file. Instead of bloating every
 tiddler with the same code, is there a more efficient way of having
 each tiddler look to the same instance of the code in a single place?

That's what plugins (tiddlers tagged with systemConfig) are for.
You could also use Markup{Pre,Post}{Head,Body} to dump the script tag, 
but that's probably not necessary.


-- F.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TiddlyWiki group.
To post to this group, send email to tiddlywiki@googlegroups.com
To unsubscribe from this group, send email to 
tiddlywiki+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en
-~--~~~~--~~--~--~---



[tw] Re: JavaScript common to multiple tiddlers

2009-10-15 Thread Eric Shulman


This FAQ article may help:

http://www.tiddlytools.com/faq.html#FAQ_ScriptsAndPlugins

enjoy
-e
Eric Shulman
TiddlyTools / ELS Design Studios
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TiddlyWiki group.
To post to this group, send email to tiddlywiki@googlegroups.com
To unsubscribe from this group, send email to 
tiddlywiki+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en
-~--~~~~--~~--~--~---



[tw] Re: JavaScript common to multiple tiddlers

2009-10-15 Thread Michael Mahemoff

This raises a related question for me - why is it good practice for
plugins to check if they've already been loaded? (if
version.extensions.) { } at the top of most plugins). I've never
seen one plugin include the entire source of another plugin, so why is
there a risk a plugin will be loaded twice?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TiddlyWiki group.
To post to this group, send email to tiddlywiki@googlegroups.com
To unsubscribe from this group, send email to 
tiddlywiki+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en
-~--~~~~--~~--~--~---



[tw] Re: JavaScript common to multiple tiddlers

2009-10-15 Thread FND

 why is it good practice for plugins to check if they've already been
 loaded? (if version.extensions.) { } at the top of most plugins)

Cargo-culting.
This doesn't actually solve any useful purpose AFAICT. I'm not sure 
where it originates, but I don't include those bits in my plugins 
anymore (though I haven't gotten around to removing it from all existing 
plugins yet).


-- F.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TiddlyWiki group.
To post to this group, send email to tiddlywiki@googlegroups.com
To unsubscribe from this group, send email to 
tiddlywiki+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en
-~--~~~~--~~--~--~---



[tw] Re: JavaScript common to multiple tiddlers

2009-10-15 Thread Eric Shulman

 This raises a related question for me - why is it good practice for
 plugins to check if they've already been loaded? (if
 version.extensions.) { } at the top of most plugins). I've never
 seen one plugin include the entire source of another plugin, so why is
 there a risk a plugin will be loaded twice?

In general, I don't include this check in my plugins.

However, I *have* seen instances where people had two different
versions of the same plugin code installed in one document, because
one of the plugin tiddlers has been renamed.  As a result, the newer
revision doesn't *replace* the old one, and both tiddlers continue to
be loaded at startup, so multiple loads *are* possible, even if it is
unintended.

Of course, for most plugins, being invoked multiple times doesn't
really matter (except for the extra processing time), as they are
typically just definining functions and variables that aren't actually
*used* until after startup processing has finished (e.g.,
config.macros.something.handler, config.options.chkSomething, etc.)

However, if a plugin hijacks a core function, or appends to the
config.formatters[], or modifies shadow tiddler definitions, or is in
any other way not *idempotent*, then multiple loads *might* result in
a serious fail.

For example, if a hijack is done twice, it will produce an infinite
recursion, because the 2nd hijack will end up overriding and then
subsequently invoking *itself* (rather than the original core function
that was hijacked the first time).  If the recursion gets trigger
during startup (e.g., when rendering the initial PageTemplate
display), then the browser just hangs (or gets a too much recursion
error).

Further, if we assume, however unlikely, that the user actually
understands what is causing this problem, there's no way to correct it
from within TW itself, and they have to resort to using an external
text editor to find and disable the errant plugin, so that they can
then open the document normally and really fix the error.

Lastly, it is possible, using various plugin-defined features such
RunTiddlerPlugin, or LoadTiddlersPlugin's init option, to invoke
plugin code *after* startup.  As noted above, any plugins that are not
idempotent at load time need to ensure that they don't get invoked
twice (or at least, detect that they were previously loaded so they
can clean up any functions/data left behind before re-initializing).

-e

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TiddlyWiki group.
To post to this group, send email to tiddlywiki@googlegroups.com
To unsubscribe from this group, send email to 
tiddlywiki+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en
-~--~~~~--~~--~--~---