Including one external JS file directly into another

N

Neo Geshel

I am seeking a method to load one JS file directly into another,
*without* having to dynamically write <script> tags.

Is there any method whereby I can call only one external JS file using a
single <script> tag, but have that external JS file insert into ITSELF
the contents of five others?

Something like:

/*start external.js*/
import ("/js/script1.js")
import ("/js/script2.js")
import ("/js/script3.js")
import ("/js/script4.js")
import ("/js/script5.js")
/*end external.js*/

TIA
...Geshel
--
*********************************************************************
My return e-mail address is an automatically monitored spam honeypot.
Do not send e-mail there unless you wish to be reported as a spammer.
Please send all e-mail to my first name at my last name dot org, with
a subject-line of “NEWSGROUP REPLY FOR NEO GESHEL†(all uppercase).
*********************************************************************
 
L

-Lost

Neo Geshel said:
I am seeking a method to load one JS file directly into another, *without* having to
dynamically write <script> tags.
Is there any method whereby I can call only one external JS file using a single <script>
tag, but have that external JS file insert into ITSELF the contents of five others?

Based on Hunlock's lovely little snippet:

http://www.hunlock.com/blogs/Howto_Dynamically_Insert_Javascript_And_CSS

I wrote:

function embed_scripts()
{
var arg_obj = String(arguments[0]);
var arg = (arguments.length == 1) ? arg_obj.split(',') : arguments;
var head_obj = document.getElementsByTagName('head')[0];
for (var i = 0; i < arg.length; i++)
{
var script_obj = document.createElement('script');
script_obj.type = 'text/javascript';
script_obj.src = arg + '.js';
head_obj.appendChild(script_obj);
}
}

It can accept either an array:

var _scripts = ['script1', 'script2'];
window.onload = embed_scripts(_scripts);

....or a comma-separated list of arguments:

window.onload = embed_script('script1', 'script2');

Now, just because it worked flawlessly for me does not mean it is bulletproof. I may not
have tested all situations or it could be coincidental that it works.

One thing for certain, it makes no attempt to check whether or not 'script1' is a valid
file.

Let's see who "slams my head against the wall." *grin*

-Lost
 
R

RobG

I am seeking a method to load one JS file directly into another, *without* having to
dynamically write <script> tags.
Is there any method whereby I can call only one external JS file using a single <script>
tag, but have that external JS file insert into ITSELF the contents of five others?

Based on Hunlock's lovely little snippet:

http://www.hunlock.com/blogs/Howto_Dynamically_Insert_Javascript_And_CSS [...]
Let's see who "slams my head against the wall." *grin*

A little research, thread "createTextNode and IE7":

<URL: http://groups.google.com.au/group/comp.lang.javascript/
browse_frm/thread/7e23f42490c301de/3441a1cc21869a10?
lnk=gst&q=createTextNode+IE+Randy+Web&rnum=1&hl=en#3441a1cc21869a10 >
 
L

-Lost

RobG said:
I am seeking a method to load one JS file directly into another, *without* having to
dynamically write <script> tags.
Is there any method whereby I can call only one external JS file using a single
<script>
tag, but have that external JS file insert into ITSELF the contents of five others?

Based on Hunlock's lovely little snippet:

http://www.hunlock.com/blogs/Howto_Dynamically_Insert_Javascript_And_CSS [...]
Let's see who "slams my head against the wall." *grin*

A little research, thread "createTextNode and IE7":

<URL: http://groups.google.com.au/group/comp.lang.javascript/
browse_frm/thread/7e23f42490c301de/3441a1cc21869a10?
lnk=gst&q=createTextNode+IE+Randy+Web&rnum=1&hl=en#3441a1cc21869a10

Thank you very much for the link.

I see now that I totally omitted testing in Internet Explorer, which subsequently crashes
version 6. Does it do this in version 7 as well (I do not have 7 installed)?

Baring in mind I am only a third through that thread, I wonder, rather than resorting to
rewriting the function to include createTextNode, I could simply append the document
before assigning it any value. That in itself stopped the crash in Internet Explorer 6,
and the script runs successfully.

Is there any apparent flaw in that assumption?

Thanks again, I'll continue reading.

-Lost
 
N

Neo Geshel

-Lost said:
I am seeking a method to load one JS file directly into another, *without* having to
dynamically write <script> tags.
Is there any method whereby I can call only one external JS file usinga single <script>
tag, but have that external JS file insert into ITSELF the contents offive others?

Based on Hunlock's lovely little snippet:

http://www.hunlock.com/blogs/Howto_Dynamically_Insert_Javascript_And_CSS

I wrote:

function embed_scripts()
{
var arg_obj = String(arguments[0]);
var arg = (arguments.length == 1) ? arg_obj.split(',') : arguments;
var head_obj = document.getElementsByTagName('head')[0];
for (var i = 0; i < arg.length; i++)
{
var script_obj = document.createElement('script');
script_obj.type = 'text/javascript';
script_obj.src = arg + '.js';
head_obj.appendChild(script_obj);
}
}

It can accept either an array:

var _scripts = ['script1', 'script2'];
window.onload = embed_scripts(_scripts);

...or a comma-separated list of arguments:

window.onload = embed_script('script1', 'script2');

Now, just because it worked flawlessly for me does not mean it is bulletproof. I may not
have tested all situations or it could be coincidental that it works.

One thing for certain, it makes no attempt to check whether or not 'script1' is a valid
file.

Let's see who "slams my head against the wall." *grin*

-Lost


Unfortunately, you seem to have a slight problem understanding the
English language.

<quote>
*without* having to dynamically write <script> tags
</quote>

What part of that sentence did you fail to understand?? And yet, you
gave me a document.createElement() solution WHICH WAS EXACTLY I DID NOT
WANT TO SEE, AS I HAVE ALREADY SEEN IT ON ABOUT 50+ PAGES OF GOOGLE
SEARCH RESULTS. This NG is the resource of last resort for me. If I
can’t find it on Google, I ask here. And I made a point of mentioning
what I *didn’t* want to see as an answer, as I have already rejected it
as being too clumsy and inelegant.

So, in summary, I am looking for a solution that DOES NOT make use of
document.createElement() in any fashion whatsoever.

Cheers.
...Geshel
--
***********************************************************************
My return e-mail address is an automatically monitored spam honeypot.
Do not send e-mail there unless you wish to be reported as a spammer.
Please send all e-mail to my first name at my last name dot org, with
a subject-line of “NEWSGROUP REPLY FOR NEO GESHEL†(alluppercase).
***********************************************************************
* “I contend that we are both atheists. I just believe in one fewer *
* god than you do. When you understand why you dismiss all the other *
* possible gods, you will understand why I dismiss yours.†*
* - Stephen F. Roberts *
***********************************************************************
* “Anyone who believes in Intelligent Design (“creationismâ€) is just *
* as ignorant, irrational and ill-educated as someone who believes *
* that the world is a flat disc, that the Sun circles the Earth or *
* that there really is a tooth fairy. Darwinism has an overwhelming *
* foundation of evidence that can be tested and reproduced. *
* *
* “Intelligent Design, on the other hand, has no evidence at all;not *
* one single shred of testable proof. As such, Intelligent Design is *
* Religious Mythology, and has no right whatsoever to be in our *
* Science classrooms.†- 99.99+% of Scientists *
***********************************************************************
Mignon McLaughlin once said that “A nymphomaniac is a woman [who is]
as obsessed with sex as the average man.†Unfortunately, sincetrue
nymphomaniacs are so rare, this means that it takes an extraordinary
woman to keep up with an ordinary man.
***********************************************************************
 
R

RobG

[...]
Unfortunately, you seem to have a slight problem understanding the
English language.

You seem to have serious misunderstanding of news groups. Ignorance
is tolerated; outright rudeness and disrespect for Usenet etiquette is
not.

It is a good idea to read the FAQ:
<URL: http://www.jibbering.com/faq/ >
 
L

-Lost

I provided you exactly that. I'll quote for a moment that your request was "*without*
having to dynamically write <script> tags."

Hunlock's article is "dynamically inserting" JavaScript (or CSS). Inserting elements is
different than "writing" a <script> tag. E.g.:

document.write('<script type="text/javascript" src="x.js">...<\/script>');

My meager function made no attempt to "write" anything. Least of all a script tag.

It did however "dynamically insert" the script element, modify its values, and then append
it to the existing head element.
Unfortunately, you seem to have a slight problem understanding the English language.

Despite the popularity of asininity in your remarks, I will refrain from partaking.
<quote>
*without* having to dynamically write <script> tags
</quote>

It was actually my direct understanding of the English language and your inability to
properly describe your request.
as I have already rejected it as being too clumsy and inelegant.

Oh really? Your alternative solution is... ?

I guess I could mention creating the source server-side, but I fear it would set you off
on another rant.
So, in summary, I am looking for a solution that DOES NOT make use of
document.createElement() in any fashion whatsoever.

Making *that* clear in the first place would have alleviated the greatest part of this
thread.
Cheers.
...Geshel

And to you.

-Lost
 
N

Neo Geshel

-Lost said:
I provided you exactly that. I'll quote for a moment that your requestwas "*without*
having to dynamically write <script> tags."

Hunlock's article is "dynamically inserting" JavaScript (or CSS). Inserting elements is
different than "writing" a <script> tag. E.g.:

document.write('<script type="text/javascript" src="x.js">...<\/script>');

My meager function made no attempt to "write" anything. Least of all ascript tag.

It did however "dynamically insert" the script element, modify its values, and then append
it to the existing head element.

Google: Javascript append content
http://www.google.ca/search?num=100...q=javascript+append+content&btnG=Search&meta=

Google: Javascript dynamic write
http://www.google.ca/search?num=100...&q=javascript+dynamic+write&btnG=Search&meta=

With the majority of the results’ subjects being the same across the two
search terms (and a number of pages being the same across both search
results), I'd say they were both about the same damn thing.

Or in other words: Po-tay-to, po-tah-to; to-may-to, to-mah-to. Same
shit, different pile.

In fact, many sites consider the two methods to be the same thing:
http://www.codehouse.com/javascript/articles/external/
and make the distinction between them by calling one a "static" method,
and the other the “DHTML†method.

And the difference between “appending†and “writing†are very slim
indeed. In either way, content gets "written" into the page, it's simply
the method that is used that changes. One uses a direct, sledge-hammer
like method, and the other uses fancy DHTML tricks to lock onto a
pre-existing tag and shoehorn the content in after the tag.

Kind of like the difference between pencilling in the margins of a book,
and making a proper footnote. The DHTML method is simply more
“professional†and more compliant with modern web standards than the
other. Otherwise, they both dynamically add content to the web page, be
it <script> tags or other stuff.

So, once again, I am *not* looking for methods that will “dynamically
insert†or “dynamically append†or “dynamically write†or “dynamically
add†or do to the web page itself any other dynamic action whose
definition you care to whimsically constrict to absurdly narrow parameters.

In other words, I am looking for a way of calling additional JS files
from within the “original†external JS file, without having <script>
tags added, in any way whatsoever, to the web page.

Just as I had originally asked. Was that really so hard to comprehend???

...Geshel.
--
***********************************************************************
My return e-mail address is an automatically monitored spam honeypot.
Do not send e-mail there unless you wish to be reported as a spammer.
Please send all e-mail to my first name at my last name dot org, with
a subject-line of “NEWSGROUP REPLY FOR NEO GESHEL†(alluppercase).
***********************************************************************
* “I contend that we are both atheists. I just believe in one fewer *
* god than you do. When you understand why you dismiss all the other *
* possible gods, you will understand why I dismiss yours.†*
* - Stephen F. Roberts *
***********************************************************************
* “Anyone who believes in Intelligent Design (“creationismâ€) is just *
* as ignorant, irrational and ill-educated as someone who believes *
* that the world is a flat disc, that the Sun circles the Earth or *
* that there really is a tooth fairy. Darwinism has an overwhelming *
* foundation of evidence that can be tested and reproduced. *
* *
* “Intelligent Design, on the other hand, has no evidence at all;not *
* one single shred of testable proof. As such, Intelligent Design is *
* Religious Mythology, and has no right whatsoever to be in our *
* Science classrooms.†- 99.99+% of Scientists *
***********************************************************************
Mignon McLaughlin once said that “A nymphomaniac is a woman [who is]
as obsessed with sex as the average man.†Unfortunately, sincetrue
nymphomaniacs are so rare, this means that it takes an extraordinary
woman to keep up with an ordinary man.
***********************************************************************
 
T

TheBagbournes

You could write a function which pulls the source in using an XHR, and evals it in a success handler function. Of course you're limited to pulling from the originating server but...
 
S

Smarty

I provided you exactly that. I'll quote for a moment that your request was "*without*
having to dynamically write <script> tags."
Hunlock's article is "dynamically inserting" JavaScript (or CSS). Inserting elements is
different than "writing" a <script> tag. E.g.:
document.write('<script type="text/javascript" src="x.js">...<\/script>');
My meager function made no attempt to "write" anything. Least of all a script tag.
It did however "dynamically insert" the script element, modify its values, and then append
it to the existing head element.

Google: Javascript append contenthttp://www.google.ca/search?num=100&hl=en&safe=off&client=firefox-a&r...

Google: Javascript dynamic writehttp://www.google.ca/search?num=100&hl=en&safe=off&client=firefox-a&r...

With the majority of the results' subjects being the same across the two
search terms (and a number of pages being the same across both search
results), I'd say they were both about the same damn thing.

Or in other words: Po-tay-to, po-tah-to; to-may-to, to-mah-to. Same
shit, different pile.

In fact, many sites consider the two methods to be the same thing:http://www.codehouse.com/javascript/articles/external/
and make the distinction between them by calling one a "static" method,
and the other the "DHTML" method.

And the difference between "appending" and "writing" are very slim
indeed. In either way, content gets "written" into the page, it's simply
the method that is used that changes. One uses a direct, sledge-hammer
like method, and the other uses fancy DHTML tricks to lock onto a
pre-existing tag and shoehorn the content in after the tag.

Kind of like the difference between pencilling in the margins of a book,
and making a proper footnote. The DHTML method is simply more
"professional" and more compliant with modern web standards than the
other. Otherwise, they both dynamically add content to the web page, be
it <script> tags or other stuff.

So, once again, I am *not* looking for methods that will "dynamically
insert" or "dynamically append" or "dynamically write" or "dynamically
add" or do to the web page itself any other dynamic action whose
definition you care to whimsically constrict to absurdly narrow parameters.

In other words, I am looking for a way of calling additional JS files
from within the "original" external JS file, without having <script>
tags added, in any way whatsoever, to the web page.

Just as I had originally asked. Was that really so hard to comprehend???

...Geshel.
--
***********************************************************************
My return e-mail address is an automatically monitored spam honeypot.
Do not send e-mail there unless you wish to be reported as a spammer.
Please send all e-mail to my first name at my last name dot org, with
a subject-line of "NEWSGROUP REPLY FOR NEO GESHEL" (all uppercase).
***********************************************************************
* "I contend that we are both atheists. I just believe in one fewer *
* god than you do. When you understand why you dismiss all the other *
* possible gods, you will understand why I dismiss yours." *
* - Stephen F. Roberts *
***********************************************************************
* "Anyone who believes in Intelligent Design ("creationism") is just *
* as ignorant, irrational and ill-educated as someone who believes *
* that the world is a flat disc, that the Sun circles the Earth or *
* that there really is a tooth fairy. Darwinism has an overwhelming *
* foundation of evidence that can be tested and reproduced. *
* *
* "Intelligent Design, on the other hand, has no evidence at all; not *
* one single shred of testable proof. As such, Intelligent Design is *
* Religious Mythology, and has no right whatsoever to be in our *
* Science classrooms." - 99.99+% of Scientists *
***********************************************************************
Mignon McLaughlin once said that "A nymphomaniac is a woman [who is]
as obsessed with sex as the average man." Unfortunately, since true
nymphomaniacs are so rare, this means that it takes an extraordinary
woman to keep up with an ordinary man.
***********************************************************************- Hide quoted text -

- Show quoted text -

*without* having to
What u want? You want to run js without specifying <script> tag in
anyway? LOL... Then pl create a browser which will detect js without
<script> tag. Hope u wont ask in future that "I want to run a webpage
without creating it" LOL....

Better Luck In Next Post

Sriram
 
N

Neo Geshel

Smarty said:
*without* having to

What u want? You want to run js without specifying <script> tag in
anyway? LOL... Then pl create a browser which will detect js without
<script> tag. Hope u wont ask in future that "I want to run a webpage
without creating it" LOL....

Better Luck In Next Post

Sriram
And if you had read the original post, you would have discovered that I
talked about having one and only one “original†external JS file that
was called by the web site (via a single hard-coded <script> tag). All
the other JS files would be called by that JS file, and called *without*
having additional <script> tags dynamically added (I have to be careful
about my terms now that the definition-police are out and about) to the
web page itself.

So please, read the original post prior to putting foot in mouth.

...Geshel
--
***********************************************************************
My return e-mail address is an automatically monitored spam honeypot.
Do not send e-mail there unless you wish to be reported as a spammer.
Please send all e-mail to my first name at my last name dot org, with
a subject-line of “NEWSGROUP REPLY FOR NEO GESHEL†(alluppercase).
***********************************************************************
* “I contend that we are both atheists. I just believe in one fewer *
* god than you do. When you understand why you dismiss all the other *
* possible gods, you will understand why I dismiss yours.†*
* - Stephen F. Roberts *
***********************************************************************
* “Anyone who believes in Intelligent Design (“creationismâ€) is just *
* as ignorant, irrational and ill-educated as someone who believes *
* that the world is a flat disc, that the Sun circles the Earth or *
* that there really is a tooth fairy. Darwinism has an overwhelming *
* foundation of evidence that can be tested and reproduced. *
* *
* “Intelligent Design, on the other hand, has no evidence at all;not *
* one single shred of testable proof. As such, Intelligent Design is *
* Religious Mythology, and has no right whatsoever to be in our *
* Science classrooms.†- 99.99+% of Scientists *
***********************************************************************
Mignon McLaughlin once said that “A nymphomaniac is a woman [who is]
as obsessed with sex as the average man.†Unfortunately, sincetrue
nymphomaniacs are so rare, this means that it takes an extraordinary
woman to keep up with an ordinary man.
***********************************************************************
 
N

Neo Geshel

TheBagbournes said:
You could write a function which pulls the source in using an XHR, and
evals it in a success handler function. Of course you're limited to
pulling from the originating server but...

That’s a start. I’ll look into it. Thanks.

...Geshel
--
***********************************************************************
My return e-mail address is an automatically monitored spam honeypot.
Do not send e-mail there unless you wish to be reported as a spammer.
Please send all e-mail to my first name at my last name dot org, with
a subject-line of “NEWSGROUP REPLY FOR NEO GESHEL†(alluppercase).
***********************************************************************
* “I contend that we are both atheists. I just believe in one fewer *
* god than you do. When you understand why you dismiss all the other *
* possible gods, you will understand why I dismiss yours.†*
* - Stephen F. Roberts *
***********************************************************************
* “Anyone who believes in Intelligent Design (“creationismâ€) is just *
* as ignorant, irrational and ill-educated as someone who believes *
* that the world is a flat disc, that the Sun circles the Earth or *
* that there really is a tooth fairy. Darwinism has an overwhelming *
* foundation of evidence that can be tested and reproduced. *
* *
* “Intelligent Design, on the other hand, has no evidence at all;not *
* one single shred of testable proof. As such, Intelligent Design is *
* Religious Mythology, and has no right whatsoever to be in our *
* Science classrooms.†- 99.99+% of Scientists *
***********************************************************************
Mignon McLaughlin once said that “A nymphomaniac is a woman [who is]
as obsessed with sex as the average man.†Unfortunately, sincetrue
nymphomaniacs are so rare, this means that it takes an extraordinary
woman to keep up with an ordinary man.
***********************************************************************
 
R

Randy Webb

Neo Geshel said the following on 2/3/2007 1:13 PM:
That’s a start. I’ll look into it. Thanks.

Thats even worse than dynamically creating a script element. But, I
won't tell the OP that, he may dicker with me about wordings (which I
couldn't care less about).

P.S. I can include as many .js files into another .js file as I want
without having to create additional script elements. But, after the
attitude of the OP in this thread I can assure you that Hell has a
better chance of freezing before I divulge it.

Then again, if the OP couldn't find out how to include one file in
another after searching Google then me telling how to do it won't
register with him.

I will say this though, there is only *one* way to accomplish the
half-assed attempt at explaining his desire without creating additional
script elements.
 
J

John G Harris

Unfortunately, you seem to have a slight problem understanding the
English language.

Some people need reminding that the internet travels round the world and
even reaches people who don't speak English at home. Some of those
people know a lot about javascript. (And some don't.)

<quote>
*without* having to dynamically write <script> tags
</quote>

Some people also need reminding that 'tag' is a technical term meaning
special things in the HTML source file, such as '<script>'.

Presumably you meant 'script element'. Even then, you didn't make it
clear that you didn't want the DOM updated with a complete script
element, even if it was done entirely inside a js file.

What part of that sentence did you fail to understand?? And yet, you
gave me a document.createElement() solution WHICH WAS EXACTLY I DID NOT
WANT TO SEE, AS I HAVE ALREADY SEEN IT ON ABOUT 50+ PAGES OF GOOGLE
SEARCH RESULTS. This NG is the resource of last resort for me. If I
can’t find it on Google, I ask here. And I made a point of mentioning
what I *didn’t* want to see as an answer, as I have already rejected
it as being too clumsy and inelegant.

So, in summary, I am looking for a solution that DOES NOT make use of
document.createElement() in any fashion whatsoever.

Surely the answer is obvious. You use your trusty text editor to merge
all the bits of js into one large js file. You can't get more elegant
than that.

If that is inconvenient you can program the server to merge the files
for you.

John


PS Your sig has Unicode characters that don't display properly in ASCII
readers.
 
N

Neo Geshel

Randy said:
Neo Geshel said the following on 2/3/2007 1:13 PM:

Thats even worse than dynamically creating a script element. But, I
won't tell the OP that, he may dicker with me about wordings (which I
couldn't care less about).

P.S. I can include as many .js files into another .js file as I want
without having to create additional script elements. But, after the
attitude of the OP in this thread I can assure you that Hell has a
better chance of freezing before I divulge it.

As long as it doesn’t involve document.write and/or
document.createElement(), then I’m all ears, because that’s exactly what
I’ve been looking for.

And that’s exactly what I’ve been asking for, from the start.
Then again, if the OP couldn't find out how to include one file in
another after searching Google then me telling how to do it won't
register with him.

Maybe I haven’t been using the correct search terms. A tool is only as
good as how you use it. I have Googled the following search terms (in
various combinations):

Javascript include dynamic dynamically insert -"document.write"
-"document.createElement" "insert one javascript file into another"

Nothing, after at least 100 search results per try. And I made quite a
number of attempts before posting here.
I will say this though, there is only *one* way to accomplish the
half-assed attempt at explaining his desire without creating additional
script elements.

Providing a taunt rather than hard evidence makes you only one thing in
my eyes:

A windbag. And a bloody big one, at that.

Either put your nuts on the line, and be helpful (as in, provide me with
what I have been asking for, from the start) or shut up.

Cheers.
...Geshel
--
***********************************************************************
My return e-mail address is an automatically monitored spam honeypot.
Do not send e-mail there unless you wish to be reported as a spammer.
Please send all e-mail to my first name at my last name dot org, with
a subject-line of “NEWSGROUP REPLY FOR NEO GESHEL†(alluppercase).
***********************************************************************
* “I contend that we are both atheists. I just believe in one fewer *
* god than you do. When you understand why you dismiss all the other *
* possible gods, you will understand why I dismiss yours.†*
* - Stephen F. Roberts *
***********************************************************************
* “Anyone who believes in Intelligent Design (“creationismâ€) is just *
* as ignorant, irrational and ill-educated as someone who believes *
* that the world is a flat disc, that the Sun circles the Earth or *
* that there really is a tooth fairy. Darwinism has an overwhelming *
* foundation of evidence that can be tested and reproduced. *
* *
* “Intelligent Design, on the other hand, has no evidence at all;not *
* one single shred of testable proof. As such, Intelligent Design is *
* Religious Mythology, and has no right whatsoever to be in our *
* Science classrooms.†- 99.99+% of Scientists *
***********************************************************************
Mignon McLaughlin once said that “A nymphomaniac is a woman [who is]
as obsessed with sex as the average man.†Unfortunately, sincetrue
nymphomaniacs are so rare, this means that it takes an extraordinary
woman to keep up with an ordinary man.
***********************************************************************
 
N

Neo Geshel

John said:
Surely the answer is obvious. You use your trusty text editor to merge
all the bits of js into one large js file. You can't get more elegant
than that.

I need to be able to load different files depending on which features
exist in the calling page. Since some of my JS files (and some of the
XML files that *they* call) are pretty hefty, I want to be able to call
them dynamically (based on what the page needs) from inside a single, JS
“handler†file, which is the only JS file that is actually called by the
web page. This will allow me to minimize the amount of bandwidth used by
a page.
If that is inconvenient you can program the server to merge the files
for you.

The server can’t feature-detect. And using a browser capabilitiesfile
is far too inelegant and ineffective. The UA can always be spoofed, but
capabilities cannot.
PS Your sig has Unicode characters that don't display properly in ASCII
readers.

There are still ASCII Usenet readers out there that can't understand
Unicode?? Wow. What are they? Are they compatible with XP? What year was
their last release date? The only one that I’ve used that didn’t have
Unicode support was Microplanet Gravity, and that’s because it died
almost a decade ago, before Unicode support became essential on the web.
It’s now abandonware, but I still use it for binaries, because ofits
unparallelled ability to sort, combine and handle binary posts. I’ve
tried to migrate to XanaNews, but it’s still too unstable for my needs.

I see (from your headers) that you’re using a client called “Turnpikeâ€.
Haven’t had much time to look at its product page, but I do notice that
the web site is still referencing Windows NT and 95 in relation to the
current version. I guess that’s why it still doesn’t haveUnicode
support... I mean, in those days the vast majority of net users were
still in North America, and being able to view anything other than
American English was a non-issue.

...Geshel
--
***********************************************************************
My return e-mail address is an automatically monitored spam honeypot.
Do not send e-mail there unless you wish to be reported as a spammer.
Please send all e-mail to my first name at my last name dot org, with
a subject-line of “NEWSGROUP REPLY FOR NEO GESHEL†(alluppercase).
***********************************************************************
* “I contend that we are both atheists. I just believe in one fewer *
* god than you do. When you understand why you dismiss all the other *
* possible gods, you will understand why I dismiss yours.†*
* - Stephen F. Roberts *
***********************************************************************
* “Anyone who believes in Intelligent Design (“creationismâ€) is just *
* as ignorant, irrational and ill-educated as someone who believes *
* that the world is a flat disc, that the Sun circles the Earth or *
* that there really is a tooth fairy. Darwinism has an overwhelming *
* foundation of evidence that can be tested and reproduced. *
* *
* “Intelligent Design, on the other hand, has no evidence at all;not *
* one single shred of testable proof. As such, Intelligent Design is *
* Religious Mythology, and has no right whatsoever to be in our *
* Science classrooms.†- 99.99+% of Scientists *
***********************************************************************
Mignon McLaughlin once said that “A nymphomaniac is a woman [who is]
as obsessed with sex as the average man.†Unfortunately, sincetrue
nymphomaniacs are so rare, this means that it takes an extraordinary
woman to keep up with an ordinary man.
***********************************************************************
 
K

Kevin Darling

Either put your nuts on the line, and be helpful (as in, provide me with
what I have been asking for, from the start) or shut up.

I've been on the net since its beginning, but this is the first time
I've felt totally compelled and justified to insult someone. Neo,
you're one of the biggest assholes I've ever seen. You ask for free
help and then bash it. No one is obligated to provide you with
jack. And now I don't see any reason for anyone to help you at all.

And dump that stupid childish giant signature. Woof.

Kev
 
N

Neo Geshel

Kevin said:
I've been on the net since its beginning, but this is the first time
I've felt totally compelled and justified to insult someone. Neo,
you're one of the biggest assholes I've ever seen. You ask for free
help and then bash it. No one is obligated to provide you with
jack. And now I don't see any reason for anyone to help you at all.

And dump that stupid childish giant signature. Woof.

Kev

Okay, so I got a little irritated. But I specifically stated what I *did
not* want to see, and yet that’s all I got in response.

I know a lot of people that post to Usenet fail to fully read the
question before answering, but I went out of my way to point out what I
did not want to see. Maybe I wasn’t specific enough, but I postedto
Usenet for a quick-and-dirty answer (or even a point in the right
direction). I had no interest in publishing an RFP.

And then R.Webb decides to taunt me by claiming to have the answer, but
refusing to tell me. That’s behaviour that is straight from
Kindergarten, if you ask me. And I’m of the rather direct opinionthat
if a person can’t put up, they should shut up.

Maybe I’m too blunt. Maybe I’m not diplomatic enough. Butwhen someone
asks a question and I decide to provide an answer, at least I read the
d*mn question that was posted in the first place, so I can avoid giving
them data that they are clearly not interested in.

As for the sig, you’re right. It’s an old one for this computer, and I
haven’t updated it with my current one in a while. Done.

...Geshel
--
***********************************************************************
My return e-mail address is an automatically monitored spam honeypot.
Do not send e-mail there unless you wish to be reported as a spammer.
Please send all e-mail to my first name at my last name dot org, with
a subject-line of “NEWSGROUP REPLY FOR NEO GESHEL†(alluppercase).
***********************************************************************
 
P

pcx99

Hi Geshel,

I had a nice article picked out which showed how to combined and (as a
bonus) compress multiple js calls. No you can't do it inside the js
itself but with a little server side script and a tweak of .htaccess you
can do it quite nicely.

However seeing how you treat people who try and pitch in to help you, I
believe I'll withhold the link.






Neo said:
-Lost said:
I am seeking a method to load one JS file directly into another,
*without* having to dynamically write <script> tags.
Is there any method whereby I can call only one external JS file
using a single <script> tag, but have that external JS file insert
into ITSELF the contents of five others?

Based on Hunlock's lovely little snippet:

http://www.hunlock.com/blogs/Howto_Dynamically_Insert_Javascript_And_CSS

I wrote:

function embed_scripts()
{
var arg_obj = String(arguments[0]);
var arg = (arguments.length == 1) ? arg_obj.split(',') : arguments;
var head_obj = document.getElementsByTagName('head')[0];
for (var i = 0; i < arg.length; i++)
{
var script_obj = document.createElement('script');
script_obj.type = 'text/javascript';
script_obj.src = arg + '.js';
head_obj.appendChild(script_obj);
}
}

It can accept either an array:

var _scripts = ['script1', 'script2'];
window.onload = embed_scripts(_scripts);

...or a comma-separated list of arguments:

window.onload = embed_script('script1', 'script2');

Now, just because it worked flawlessly for me does not mean it is
bulletproof. I may not have tested all situations or it could be
coincidental that it works.

One thing for certain, it makes no attempt to check whether or not
'script1' is a valid file.

Let's see who "slams my head against the wall." *grin*

-Lost


Unfortunately, you seem to have a slight problem understanding the
English language.

<quote>
*without* having to dynamically write <script> tags
</quote>

What part of that sentence did you fail to understand?? And yet, you
gave me a document.createElement() solution WHICH WAS EXACTLY I DID NOT
WANT TO SEE, AS I HAVE ALREADY SEEN IT ON ABOUT 50+ PAGES OF GOOGLE
SEARCH RESULTS. This NG is the resource of last resort for me. If I
can’t find it on Google, I ask here. And I made a point of mentioning
what I *didn’t* want to see as an answer, as I have already rejected it
as being too clumsy and inelegant.

So, in summary, I am looking for a solution that DOES NOT make use of
document.createElement() in any fashion whatsoever.

Cheers.
...Geshel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,701
Latest member
XavierQ83

Latest Threads

Top