Javascript Directory to find all JScripts

M

Mel

is there a way of pointing to a directory where all JScripts are
living and let it pick and choose what it needs from which scripts or
do I have to do the picking through files each time I write a script
that depends on others ?

sorry if its a newbeeeee question, but had to ask.

I did Google but could not find anything
 
S

shimmyshack

is there a way of pointing to a directory where all JScripts are
living and let it pick and choose what it needs from which scripts or
do I have to do the picking through files each time I write a script
that depends on others ?

sorry if its a newbeeeee question, but had to ask.

I did Google but could not find anything

you could write a function that conditionally includes other files
based on what it needs, you should check out the conditional include
amde at the end of the scriptaculous library
 
R

RobG

is there a way of pointing to a directory where all JScripts are
living and let it pick and choose what it needs from which scripts or
do I have to do the picking through files each time I write a script
that depends on others ?

The usual idea is to bundle all the script you need for a site into a
small number of script files (say one to three) then minify them. Use
the same set of scripts on every page so they are cached and your
visitors should only need to load them once in a while. Manage
scripts on a per site basis.

Don't use conditional script loading unless you can prove quantifiable
benefits - the overhead in using them from the added complexity when
maintaining a site is nearly always way out of proportion to the
minimal perceived benefits.
 
S

shimmyshack

The usual idea is to bundle all the script you need for a site into a
small number of script files (say one to three) then minify them. Use
the same set of scripts on every page so they are cached and your
visitors should only need to load them once in a while. Manage
scripts on a per site basis.

Don't use conditional script loading unless you can prove quantifiable
benefits - the overhead in using them from the added complexity when
maintaining a site is nearly always way out of proportion to the
minimal perceived benefits.

I agree with that, and also I would say that you can get great
compression with mod_deflate or gzip. Obviously if you have an app
which required 6 js pages, why not simply make 1 large page, avoid the
other 5 requests, and use deflate to compress the source to 15% of its
original size, no minifying needed.
 
L

-Lost

I agree with that, and also I would say that you can get great
compression with mod_deflate or gzip. Obviously if you have an app
which required 6 js pages, why not simply make 1 large page, avoid the
other 5 requests, and use deflate to compress the source to 15% of its
original size, no minifying needed.

I would see:
http://www.thinkvitamin.com/features/webapps/serving-javascript-fast on
the appropriateness of mod_gzip in comparison to mod_deflate.

There are plenty of articles on this actually.
 
D

Dr J R Stockton

In comp.lang.javascript message <[email protected]
is there a way of pointing to a directory where all JScripts are
living and let it pick and choose what it needs from which scripts or
do I have to do the picking through files each time I write a script
that depends on others ?

To the question as asked, AFAIK no, at run time.

An author can of course write an authoring tool that, given the name of
a function or other variable, will search within a directory and import
its definition.

My "javascript library" is contained within about 5 *.js files,
classified by topic, and on each page that needs to use routines from it
I include the corresponding file by reference, by for example
<script type="text/javascript" src="include1.js"></script>

See <URL:http://www.merlyn.demon.co.uk/js-nclds.htm.>

Normally I know which file a function is in; otherwise, I use a search
tool such as MiniTrue.
 
S

shimmyshack

I would see:http://www.thinkvitamin.com/features/webapps/serving-javascript-faston
the appropriateness of mod_gzip in comparison to mod_deflate.

There are plenty of articles on this actually.

that is true... it's harder to setup for mod_deflate, as browsers
generally ask for gzip, although the argument is valid, I haven't to
date found anyone who has been tripped up by gzip. If your server is
beefy enough to handle it great, else look for the accept-encoding
deflate, and serve that if at all possible I agree.
Theres also another valid point on that link, if you have a HUGE file
of js, then make sure you wont have to make changes to it, or you will
force a download of that file, on the plus side even if you start with
200k of js which is a lot, it will generally hover around 36k
compressed, which isnt too bad - the cost of an image.
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top