Hi,

>    function addScript( url ) {
>       var script = document.createElement( 'script' );
>       script.type = 'text/javascript';
>       script.charset = 'utf-8';
>       script.src = url;
>       document.getElementsByTagName('head')[0].appendChild( script );
>    };

There are some Safari versions that won't execute scripts like this. The 
solution is to load the script with a XMLHttpRequest and eval it.

The second drawback of that solution is that you can not resolve dependencies 
between dynamically loaded scripts. Well you can, but then you have to keep 
the dependency-informatin in a central place.

> However, it may or may not be a good idea. Loading your plugin scripts
> dynamically will reduce the number of files loaded in HEAD, but the overall
> load time won't be any better. Loading a number of different scripts will
> take time however you do it.

Yes, but you can delay the loading of some scripts. That way your page starts 
up very fast and some scripts can be loaded after startup or even on demand. 
Dynamically loaded scripts can also dynamically load other scripts and 
resolve dependencies that way.

You may also build your page with a CMS. Then you insert a script-tag 
hardcoded in your template and have that script decide which plugins to load 
based on the contents of the page.

Christof

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to