That's how jQuery loads scripts from remote domains  now, allowing
cross-domain requests.

Cheers

--
Ariel Flesler
http://flesler.blogspot.com/

On Mar 28, 12:49 pm, sotretus <[EMAIL PROTECTED]> wrote:
> Guys,
>
> I was looking the code for the getScript() function and I saw that
> when the javascript (text) file is received you "eval()"uate it, thus
> executing what is inside. This seems to be a rather common way of
> loading javascript since I have seen it in other frameworks as well.
>
> Still, I've been using another approach that seems to work fine (at
> least) in FF and IE. Insted of getting the file and evaluating it, I
> just add a new SCRIPT element to the HEAD of the document with the
> specified URL. The main difference with this is that I can check if
> that script was already loaded (maybe by another component) and thus
> avoid loading it twice.
> (something like this:
>
> [code]
>         var script = document.createElement('script');
>         script.type = 'text/javascript';
>         script.src = uri;
>         document.getElementsByTagName('head')[0].appendChild(script);
> [/code]
>
> (Of course I am not checking for anything, but just to clarify)
>
> I am pretty sure that there is a good reason why to use eval instead
> of my approach, but I just wanted to know why.
>
> Cheers
> AB

Reply via email to