Call 2 javascript files into one

SeLecTeD

Regular Member
Joined
Mar 21, 2010
Messages
274
Reaction score
38
I've got these 2 redirect codes from JuicyADS.

Code:
<script type="text/javascript">juicy_code='XXX';</script><script type="text/javascript" src="http://ads.juicyads.com/jsclients/jac.js" charset="utf-8"></script>


<script type="text/javascript" src="http://ads.juicyads.com/jsclients/jam_min.js"></script>
<script type="text/javascript">window.onload=check_mobile(XXX,XXX)</script>


How can I merge this html code into one .js file ?

I want to call this code in one line: <script type="text/javascript" src="http://mydomains.com/myfile.js"></script>

Thanks guys !
 
Save them both to your hard drive, then under linux you would do:

cat jac.js jam.js > myfile.js

echo "<script type=\"text/javascript\">window.onload=check_mobile(XXX,XXX)</script>" >> myfile.js


You can get linux tools for windows, it's called cygwin.
 
I do not want to cache them down on my local, because they are dynamic files (other people adding lines/deleting lines)...
I don't know how to call those files in a js one...
 
Sure, you can, although it's not such as "importing" a new one.

Use the following:

Code:
var script   = document.createElement("script");
script.type  = "text/javascript";
script.src   = "http://ads.juicyads.com/jsclients/jam_min.js";
document.body.appendChild(script);
 
You mentioned you wanted to call 2 Js's into one. I have no idea what you're trying to do. ttrox's solution is the same as having a HTML file with the script tags in it.
 
I basically want to merge them into one .js file.

So my .js file will be like:
Code:
juicy_code='XXX';
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "http://ads.juicyads.com/jsclients/jam_min.js"; 
document.body.appendChild(script);

window.onload=check_mobile(XXX,XXX)
var script = document.createElement("script1");
script.type = "text/javascript";
script.src = "http://ads.juicyads.com/jsclients/jac.js";
document.body.appendChild(script1);
 
I don't know about the check_mobile function, where it's called from. I also do not know why you would want to do this, but that should work out for what you said.
 
I want to do this because on the website I will post this code they remove "window.onload=check_mobile(XXX,XXX)" and juicy keywords. I am trying to find a method to avoid this...
 
Back
Top