473,508 Members | 2,032 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to source another .js from within the .js defined in a script tag?

Hi gurus,

1. foo.html has a script tag to reference'foo.js'
2. foo.js wants to use the handy datadumper.js routines
3. How does foo.js become aware of functions in the datadumper.js
namespace?

Is this possible? I'm sure it must be?

Assuming it is....

In JS programming, is there a best practice for building these
'libraries'? Do JS-ers tend to divide the function sets into numerous
external files based on function? By this i mean:

1. greatsite.html uses script tag to reference 'general.js'
2. general.js sources 'ui_widgets.js' and 'transaction.js' and
'word_frobnicate.js', etc.

I'm pretty sure the first half is covered in this a FAQ...but i can't
seem to find it...

Aug 22 '06 #1
1 1372

st**********@gmail.com wrote:
Hi gurus,

1. foo.html has a script tag to reference'foo.js'
2. foo.js wants to use the handy datadumper.js routines
3. How does foo.js become aware of functions in the datadumper.js
namespace?
Being an interpreted language it doesn't need to know about it until
execution.
>
Is this possible? I'm sure it must be?
Sure, include a script tag for both foo.js and datadumper.js in your
web resource (HTML, etc.)
>
Assuming it is....

In JS programming, is there a best practice for building these
'libraries'? Do JS-ers tend to divide the function sets into numerous
external files based on function? By this i mean:

1. greatsite.html uses script tag to reference 'general.js'
2. general.js sources 'ui_widgets.js' and 'transaction.js' and
'word_frobnicate.js', etc.
Typically only if:

1. Each group of code provides very specific and different functions
and
2. The code is getting too large to download quickly.

I've seen code where there is a base package of utility method/objects
and then additional other pieces of code you can include for specific
functions.

You'll see this alot with Google Maps. You've got your script that
includes the base map functions, then there are helper apps out there
like daylight map and Jef Poskanzer's Clusterer script.
>
I'm pretty sure the first half is covered in this a FAQ...but i can't
seem to find it...
Aug 22 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
3174
by: jonathan.beckett | last post by:
Hi All, For the past few months I have been working on an open source Apache/PHP/MySQL content management system - and have recently made it available for download. It's still very much a...
4
11475
by: MLH | last post by:
I am having failures processing the following command and I wonder if you can tell me what I must do in order to have success. When I try to run source mysql_dump.sql.txt ==> it is a problem...
29
2238
by: Bill Marsden | last post by:
Hi. I am an under-graduate currently studying Open Source (Linux) vs Closed Source and Collaboration within the IT Community. I am fairly new to Javascript and I have written a "Lottery Program"...
8
5345
by: Brett Robichaud | last post by:
I understand how code-behind can handle events for a page, but can I call a code-behind method from within a <script> tag in my ASP.Net page, or can I only call methods defined in other <script>...
0
7227
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7127
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7331
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
5633
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5056
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3204
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1564
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
768
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
424
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.