how to build a library in JS

B

bluesky

Hi All,
I am new to javascript and intend to build a custom library. After
saving independent files which contain separate functions, how does one
build the library?

Any help is a great help!! Thanks in advance

Thanks
ananth
 
T

Tom Cole

You can either join all the .js files into one and distribute it, or
the end user will have to include each separate file with a <script
src="..."> tag.

If the separate files have dependencies on other files, I would put
them together. I don't think there's any guarantee the browser will
process the .js files in the order they're specified.
 
D

Dr John Stockton

JRS: In article <[email protected]>
, dated Wed, 16 Aug 2006 12:46:02 remote, seen in
news:comp.lang.javascript said:
I am new to javascript and intend to build a custom library.

Then you are probably trying to run before learning to walk.
After
saving independent files which contain separate functions, how does one
build the library?

With a text editor.

In languages such as Borland Pascal and Delphi, one can include any
amount of library code in a compilation, and only the needed parts will
be included in the final executable. Web Javascript lacks such a
capability, and, as it is repeatedly transmitted over links which may be
slow, a thoughtful page author will be careful to send only what may be
used to his readers.

Your basic library should therefore be like a public library; users take
and use only what they want. It should not be like the traditional
Encyclopaedia, for which if you want to own any particular article
legitimately you need to buy and store the whole work.

Web site authors should package the routines that will be repeatedly
used in a site within one or more "include files", generally according
to topic; and each page should only call for the include files that it
will use.

Remember, though, that include files should be cached locally to the
reader.

Read the newsgroup and its FAQ.
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top