jquery: how to include other .js-files into .js

Heinrich picture Heinrich · Apr 8, 2010 · Viewed 71.9k times · Source

Is there any jquery plugin (instead of incldeMany) or simple function to include js-files on demand ?

for example:

$.include('myscript.js'); 

?

Answer

Olly Hodgson picture Olly Hodgson · Apr 8, 2010

How about jQuery.getScript()? It's built in to jQuery and works like so:

$.getScript('ajax/test.js', function() {
    alert('Load was performed.');
});