[dokuwiki] Re: JavaScript include conditionals

  • From: Chris Smith <chris@xxxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Sat, 20 Jan 2007 15:43:50 +0000

Martin Tschofen wrote:
I wasn't thinking that DW checks if blocks are identical, I was just
assuming it compares names of blocks or scripts. Granted that could cause
all kinds of issues, hence the idea of script.ini.

How would helper plugins work properly with templates? I noticed that when
attaching an event in the js file before any of the called objects are
loaded can cause problems.
Wouldn't loading more plugins cause a performance issue as well?
What about naming? I'd be inclined to name it something weird like aaaHelper
to insure that it loads first. Or do we then need some other mechanism to
make sure that certain plugins load first?

For a helper plugin to just load a script and maybe a css file, would it
just contain a class definition inside main.php?

I'm game either way...martin

I don't see how a script.ini solves any issues at least not for plugins.

Templates need to know nothing about plugins. Plugin javascript and css is prepared for the template by DokuWiki.

JS can only affect those parts of the page loaded at the time the js is executed. The normal process is to include your script in the HEAD and to attach a listener to the window's onload event, so that the listener is fired after the document is complete. DokuWiki provides a simple mechanism for attaching listeners that doesn't conflict with DW's own onload listeners, details can be found at splitbrain. If you wish your javacript to execute before onload and for it to operate on certain parts of the page, you need to use script tags in the BODY located after the element you want to manipulate.

Plugins shouldn't need to worry about the order in which they get called.

Having more plugins is likely to have an effect on performance. Most likely the incremental effect will be minimal, although that will depend on how well written the plugin is and what it is attempting to do. Javascript is usually cached by the browser, so having a single file that is a little larger is probably more efficient that having multiple smaller files only requested on demand or having a single file that changes its content often.

fwiw, I have developed quite a few plugins and in the wiki I use to develop them I have also installed quite a number by other people. Even enabling all (20+) of them has very little effect on DW performance. Most of the time DW works from cache, for wiki pages, javascript and css.

Of course if your wiki audience is using slow dial up connections your sensitivity to page/file size may be different from mine.



DokuWiki mailing list - more info at

Other related posts: