Dastar...
Your Source For Information
46443 Articles Listed





Search:



Using External JavaScript Files

When you have lots of JavaScript functions and you plan to use
them on many web pages, it is always advisable to keep them in a
separate file, and then include that file on every page where
those functions are required. This way, you can better organize
them, you don't have to copy/paste the code again and again
(imagine if it runs to 100 or more lines!!), and you'll be forced
to write more generalized code for better integration and
scalability.

Besides, enclosing the common JavaScript routines in external
files keeps your web pages uncluttered and search engine spiders
and crawlers are able to reach the important content easily. They
don't have to shuffle through tens of lines of scripts.

In the first edition [that appeared in my newsletter - BYTESWORTH
REACHOUT] of my article I had omitted the process of creating the
external JavaScript files, but when one of my readers asked me
how to do it, I had to re-write the article.

It's very simple. Use any text editor of your liking (if you
hand-code your HTML, you can use the same editor that you use for
your HTML editing). Write the required code, and save the file
with .js (dot js) extension.

I'm going to give you a small example.

Suppose your JavaScript file is "myjfuncs.js".

and it has a function to return the bigger number of the two
supplied as parameters (you can simply start with the function,
no need to write

So when we use one of its functions in a JavaScript:



In this way, we can use all the complex functions contained in
the myjfuncs.js file.

About the Author

Amrit Hallan is a freelance web designer. For all web site
development and web promotion needs, you can get in touch with
him at amrit@bytesworth.com or http://www.bytesworth.com. For
more such articles, visit http://www.bytesworth.com/articles You
can subscribe to his newsletter [BYTESWORTH REACHOUT] on Web
Designing Tips & Tricks by sending a blank email at
bytesworth-subscribe@topica.com
Item Bids Price Ends
Programming BASICS Using MS VB, C++, HTML & Java 2002 e
Programming BASICS Using MS VB, C++, HTML & Java 2002 e
Programming BASICS Using MS VB, C++, HTML & Java 2002 e
$26.00
1d 16h
using what you got by karen e. quinones-miller
using what you got by karen e. quinones-miller
0
$2.99
2d
Special Edition Using Adobe Creative Suite 2 (Special E
Special Edition Using Adobe Creative Suite 2 (Special E
0
$5.87
2d 19h
Special Edition Using Crystal Enterprise 8.5 (Special E
Special Edition Using Crystal Enterprise 8.5 (Special E
0
$5.00
2d 19h
Special Edition Using Microsoft Project 2000 (Special E
Special Edition Using Microsoft Project 2000 (Special E
0
$4.87
3d 18h
E-Bead Buddies Book, 32 Designs Using Wire and E Beads
E-Bead Buddies Book, 32 Designs Using Wire and E Beads
0
$2.99
4d
Using Quality to Redesign School Systems: The Cutting E
Using Quality to Redesign School Systems: The Cutting E
0
$2.22
4d 8h
Special Edition Using Adobe Creative Suite 2 (Special E
Special Edition Using Adobe Creative Suite 2 (Special E
0
$3.49
4d 9h
Special Edition Using Microsoft Outlook 2000 (Special E
Special Edition Using Microsoft Outlook 2000 (Special E
0
$4.87
5d 21h
Using Excel Visual Basic for Applications, Special E...
Using Excel Visual Basic for Applications, Special E...
0
$1.17
6d 5h
Using French: A Guide to Contemporary Usage by R. E. Ba
Using French: A Guide to Contemporary Usage by R. E. Ba
0
$65.95
6d 8h
Special Edition Using Microsoft Outlook 2002 (Special E
Special Edition Using Microsoft Outlook 2002 (Special E
0
$4.18
6d 15h
Using Spanish Synonyms, R. E. Batchelor, Book
Using Spanish Synonyms, R. E. Batchelor, Book
0
$24.81
6d 22h
Desktop Publishing Using Wordperfect by Jack E. John...
Desktop Publishing Using Wordperfect by Jack E. John...
0
$1.00
7d 2h
NEW E-Justice: Using Information Communication Techn...
NEW E-Justice: Using Information Communication Techn...
0
$180.00
7d 18h
Using Spanish Synonyms, R. E. Batchelor USED Good Condi
Using Spanish Synonyms, R. E. Batchelor USED Good Condi
0
$16.82
7d 21h
Using Quality to Redesign School Systems: The Cutting E
Using Quality to Redesign School Systems: The Cutting E
0
$2.22
8d 5h
E-Commerce Applications Using Oracle8I and Java from...
E-Commerce Applications Using Oracle8I and Java from...
0
$2.00
10d 2h
Special Edition Using Microsoft Project 2000 (Special E
Special Edition Using Microsoft Project 2000 (Special E
0
$10.83
10d 9h
Using Rhetoric By John E. Jordan
Using Rhetoric By John E. Jordan
0
$3.25
11d 23h
Using communication, Richard E Crable, Good Book
Using communication, Richard E Crable, Good Book
0
$1.00
12d 12h
NEW Using Macromedia Studio - Molly E. Holzschlag
NEW Using Macromedia Studio - Molly E. Holzschlag
0
$28.88
12d 14h
Barnes and Noble Basics Using Your Digital Camera: An E
Barnes and Noble Basics Using Your Digital Camera: An E
0
$5.20
13d 10h
Using Reality Therapy, Robert E. Wubbolding, Good Book
Using Reality Therapy, Robert E. Wubbolding, Good Book
0
$2.00
13d 14h
Special Edition Using Macromedia Director MX (Special E
Special Edition Using Macromedia Director MX (Special E
0
$3.00
14d 12h
  View all items on eBayDisclaimer  
These results were generated from eBay on 01-9-2009 3:16 pm.
eBay Marketplace
Using External JavaScript Files