Reputation: 68710
Is it better (in any way) to use jQuery's getScript to load the external JS than linking the javascripts manually in the html?
Upvotes: 0
Views: 614
Reputation: 138097
You may want to delay loading and executing the script until you need it - the page will load faster if it is loaded dynamically.
In addition, the callback is very handy.
Upvotes: 2
Reputation: 188114
If the javascript file you want to load is somewhat optional, e.g. for a specific browser or maybe geolocation, i'd use getScript
; otherwise I'd see no need to push the 'include' further down in the page loading process than a plain html script
.
If you are concerned about performance, i would guess that the 'plain-method' is faster, but I haven't tested it. For web page load time performance tuning, there is a nice tool, called yslow, which is a firebug extension.
Upvotes: 4
Reputation: 30442
Can you rephrase the question? Linking them manually in the html? You mean, the urls to the scripts? You could generate them with your back-end (whatever that may be)... but... of course you need a url to load a script and jQuery can't -- I don't know -- guess or something :)
Upvotes: 0