Hi,

> That looks really dodgy, sorry.
>
> What if the browser downloads script and script2 at the same time, and
> script2 finishes first?

It doesn't. script2 is not downloaded at all, it is like a inline script. As 
you might know scripts are evaluated in the order they are in the HTML code, 
that is that script will be evaluated before script2 is.

It does work in all browsers I have tested jsPax with. The only problem I know 
of is that script2 will also be evaluated if script can not be loaded 
sucessfully. Then as soon as the browser knows that it can not load script, 
it evaluates script2.

> Instead, simply edit your copy of jquery.js and add one like of code at the
> end of the file, to call a "ready" function that you've defined in your
> already-running code. If you have jQuery plugins that your code depends on,
> merge them all into jquery.js and add that function call at the very end.

I have a simple line at the end of jquery.js:

$package('jquery',{});

The plugins are wraped with 

$using('jquery', function() {
        ...
        $package('jquery.myplugin',{});
});

If I then decide, I need the foo- and the bar-plugin in my code I simply do

$using(['jquery.foo','jquery.bar'], function() {
        alert('jquery and foo plugin are loaded now');
});

That way I load much of the needed functions on demand. Which reduces startup 
time - paied with eventual delays at the first use of some functions.

Christof

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to