[Bese-devel] javascript

Alexander Kjeldaas alexander.kjeldaas at gmail.com
Tue Jun 27 00:30:20 UTC 2006

On 6/27/06, Lou Vanek <vanek at acd.net> wrote:
> The following is what i use for clisp to delay javascripts
> from executing until the page has finished loading.

I'm no javascript expert, but do you have the HEAD/BODY
placement of your scripts correct?
AFAIU, these are the rules:
You can't do any load-time modifications to the page
from a script placed in the HEAD section.  All HEAD
scripts can be asyncronously executed (or in order but
independent of BODY and rendering of the page).
That means you cannot have any script in the BODY
section that calls scripts loaded from the HEAD section.
So, if you want to do stuff at (the end of) load-time that
calls some dojo magic, dojo.js must be loaded from the
BODY section and not from HEAD.
When events can start triggering, all HEAD scripts
must be loaded, and it looks like your magic hooks
all functions into an events-can-start-to-trigger-now event
(onload or similar), but I don't see how this is different
from loading dojo.js from the BODY section.

This is probably obvious, and in that case, sorry for
the noise :-)

Btw, with a real js-aware "compiler" or such, it should
be possible to write a tree-shaker that could additionaly
split js-functions into HEAD and BODY parts ;-).


More information about the bese-devel mailing list