Web-Development-Tutorials Home

Web Development Tutorials
HTML Tutorials
CSS Tutorials
Javascript Tutorials


Web Development Tutorials and Resources for Web Developers
from Beginners to Professionals

Linking to an External Javascript File

If you want to run the same Javascript on more than one web page, you can write the Javascript to an external Javascript file. Simply write the Javascript code in a file and save the file with a .js extension.

To link to an external Javascript, open an html file and insert the Javascript <script> tags where you would normally place them, with "src="file.js" within the openning tag.

In the following example, I will link the html file to an external Javascript file that will make the background yellow and write the text "Free-Javascript-Tutorial.com"

<script language="javascript" src="your-external-javascript-file.js">


Save the html file. Now open another file and write the following Javascript without the openning and closing <script> tags and save the file with a ".js" extenstion:

document.bgColor = "yellow";

To view the page that this Javascript code example produces, click Javascript Code Example

Web Development Resources

Free Hit Counters
Free Music and
Online Radio Stations

Free SEO Tools
Free Page Rank Checker
Free Back Link Checker
Free Google Banned Checker
Free Keyword Density Checker
Free Link Popularity Checker
Free Search Engine Keyword Position Checker
Free Search Engines Lisitings Preview
Free Link Extractor
Free Source Code Viewer
Free Domain Tools
Free Domain Name Availability Tool
Free Domain Whois Lookup
Free Ping Test
Free Reverse/IP Lookup
Misc Free Web Development Resources View Web Browser Details