JQuery getScript vs embedding script in file

I was wondering if jQuery getScript should be used or not.

I have a jQuery plugin that I need to include in my site, but I'm not sure what to do, and I am wondering if there is a difference between these approaches:

In my case, I have to include a fairly large script, but only for IE browsers. At this moment, I am doing it like this:

if($.browser.msie){
 //minifed code
}

Now I was wondering if this:

if($.browser.msie){
 $.getScript('link to minified script');
}

will have any advantages / disadvantages? Or if it is more or less the same thing?

+5
source share
6 answers

There will be flaws when creating an external script.

i.e. ONE HTTP request

if($.browser.msie){
 //minifed code
}

Two HTTP requests

 if($.browser.msie){
 $.getScript('link to minified script');
}

HTTP- . .

getScript, IE ( " " ). script (+ script * ) + - HTTP-.

- (+ ).

, minifed- 5K, 10 , :

IE GetScript:

(5K * 10) + HTTP- = 50K +

Non-IE

0

////////////////////////////////////////////////////////

IE nonGetScript

5K

IE

5K

+2

:

if($.browser.msie){
 //minifed code
}

.getScript() .

+3

. script, , , - , . script , , , , script ..

+1

. , , script, . , .

apporach , script js , , , IE. , .

, script . script js . , .

+1

, , , getScript script , . () jQuery JavaScript, script. , , script, , , .

0

script , , , . $.getScript $.ajax dataType script, script .

0

All Articles