Forum Moderators: open

Message Too Old, No Replies

merge 2 scripts but still work independently

         

solof

12:59 pm on Jun 27, 2010 (gmt 0)

10+ Year Member



Noob-alert.

I would like to make the 01.js & 02.js into one JS-file but the 2 codes still need to work independent. The following example calls the javascript which need to be merged:
<script>e9=new Object();e9.size="728x90";e9.addBlockingCategories="Pop-under,Pop-up";e9.noAd=1;</script><script src=01.js></script>

<script>sr_adspace_id = 1;sr_adspace_width = 728;sr_adspace_height = 90;sr_ad_new_window = true;sr_adspace_type = "graphic";</script>
<script src=02.js></script>

How can I use the statements (ie., sr_adspace_type, e9.size, etc...) to run the right script when integrated into 1 file?

daveVk

12:08 am on Jun 28, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



My guess is that <script src=01.js></script> inserts something into the page at the current position and dito for 02. So unless they are adjacent, combining them will not work.

solof

10:03 am on Jun 28, 2010 (gmt 0)

10+ Year Member



isnot it possible to use if/else-statement? if so, how?

daveVk

1:47 pm on Jun 28, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, good idea

combined.js

if(typeof e9 !== ‘undefined’) {
... code from 01.js ...
e9 = undefined;
}
if(typeof sr_adspace_id !== ‘undefined’) {
... code from 02.js ...
sr_adspace_id = undefined;
}