Load jQuery by javascript and run a function from another file
<p>I need to load 3 jquery scripts in a page. For business reasons i've to make the minimum modifications possible so i've decided to create one javascript to be included in the website.</p>

<p>After that, this script must load the jQuery and also 3 more jquery scripts besides 3 css files.</p>

<p>Basically, until now, that's what i've got:</p>

<pre><code>var jquery = document.createElement('script');
jquery.type = "text/javascript";
jquery.src = "common/com/jquery/jquery-1.9.1.js";
document.getElementsByTagName('head')[0].appendChild(jquery,document.getElementsByTagName('head')[0].firstChild);

var prettyPhoto = document.createElement('script');
prettyPhoto.type = "text/javascript";
prettyPhoto.src = "common/com/prettyPhoto/jquery.prettyPhoto.js";
document.getElementsByTagName('head')[0].appendChild(prettyPhoto,document.getElementsByTagName('head')[0].firstChild);

var jqueryui = document.createElement('script');
jqueryui.type = "text/javascript";
jqueryui.src = "common/com/jqueryui/jquery-ui.js";
document.getElementsByTagName('head')[0].appendChild(jqueryui,document.getElementsByTagName('head')[0].firstChild);

var kohlerApp = document.createElement('script');
kohlerApp.type = "text/javascript";
kohlerApp.src = "common/js/lelak.js";
document.getElementsByTagName('head')[0].appendChild(kohlerApp,document.getElementsByTagName('head')[0].firstChild);

var style = document.createElement("link");
style.type = "text/css";
style.href = "common/css/style.css";
style.rel = "stylesheet";
document.getElementsByTagName('head')[0].appendChild(style,document.getElementsByTagName('head')[0].firstChild);

var jqueryui = document.createElement("link");
jqueryui.type = "text/css";
jqueryui.href = "common/css/jquery-ui.css";
jqueryui.rel = "stylesheet";
document.getElementsByTagName('head')[0].appendChild(jqueryui,document.getElementsByTagName('head')[0].firstChild);

var prettyPhoto = document.createElement("link");
prettyPhoto.type = "text/css";
prettyPhoto.href = "common/css/prettyPhoto.css";
prettyPhoto.rel = "stylesheet";
document.getElementsByTagName('head')[0].appendChild(prettyPhoto,document.getElementsByTagName('head')[0].firstChild);

lelakApp.giveError("0","test");
</code></pre>

<p>I'm trying to execute one of jquery functions contained in one of the scripts included but with no success. Returns the following error:</p>

<pre><code>Uncaught ReferenceError: lelakApp is not defined 
</code></pre>

<p>(Where <strong>lelakApp</strong> is from my script)</p>

<p><strong>How can i load the jQuery and a Personal Jquery Script and load a function from that personal script, together?</strong></p>

<hr>

<p><strong>EDIT</strong></p>

<p>I'm trying to execute a simple request of jquery using <strong>requireJs</strong></p>

<pre><code>define(["../com/jquery/jquery-1.9.1"], function($) {
$('body').html('');
});
</code></pre>

<p>but i'm receiving this error:</p>

<pre><code>Uncaught TypeError: undefined is not a function
</code></pre>
