Home > Computers & Technology > Internet > Web Design
Created on: December 30, 2008
A Javascript library is a file containing a set of Javascript functions. Javascript libraries are among the most useful tools in web development, and are by far the best way to integrate Javascript into your website.
Javascript library files will typically end with a ".js". To include them in your website, in the head section, you'll include script tags that look something like, "<script type="text/javascript" src="mylibrary.js"></script>". Functionally, this would work the same as eliminating the src attribute from the opening script tag, then copying and pasting the contents of mylibrary.js within the script tag, but there are a few advantages to using the library file instead.
The first advantage is faster browsing for your website's users. Your web browser stores copies of files from websites on your computer so that if they need to be retrieved again, they can be loaded from your computer rather than waiting for them to be downloaded from the web server again. If the Javascript functions are in a separate file, that file will be cached. If they're included as a part of the web page itself, they'll have to be downloaded again for each page.
The second advantage is related to the first. Since the information does not need to be downloaded over again for every page, there is less work for the web server to do. The server will be able to more easily handle more people visiting your page.
The third advantage is a decrease in the amount of storage space you'll use up on your web server. You'll only need the library - a single copy - to use the same scripts across multiple pages, rather than having to copy the same information into the head section of each page.
The fourth advantage will probably be a favorite for the web developer. If you need to change the scripts later on, either to change how the page works or because you find out that a script contains an error, it will be easier to edit, since you will only have to change one file. If you include the scripts in the web pages, you'll have to open every file and change the script in it. In this way, Javascript libraries can be a huge time saver.
The fifth advantage is portability. You may want to use the same Javascript functions in more than one page. For example, you may have multiple pages that use AJAX functions to load only part of a page, or you may have multiple pages that use similar photo galleries. Using the same script across multiple pages will be as simple as copying the file from one website's server to the other's, and including the link at the top of each page. This is yet another time saver.
You can write your own Javascript libraries, or you can search for them online. If you're using one that someone else wrote, just be sure that you completely understand how it works. You may want to tweak it slightly to better suit your purposes, and you'll want to be able to do that without messing up something that already works. Also, learning how other people's Javascript functions work is a great way for you to learn more Javascript yourself!
Learn more about this author, David Hockenbroch.
Click here to send this author comments or questions.
Below are the top articles rated and ranked by Helium members on:
What a Javascript library is
So just what are Javascript Libraries?
Javascrip t libraries are files that can be downloaded from sites such as script.aculo.us
A Javascript library is a file containing a set of Javascript functions. Javascript libraries are among the most useful
by Max Lehmann
In computing terms a library isn't what the layman would expect. Libraries for most people conjure up images of buildings
Helium Debate
Cast your vote!
What type of Internet portal is best for promoting your work: A traditional website or a blog?
Click for your side.
Featured Partner
Promoting the health and well-being of Americans through programs and activities.more