<SCRIPT ARCHIVE="..."> (HTML Tag Attribute)

The URL to access an archive containing insertable fragments of JavaScript contained in a single file.

Availability:

JavaScript - 1.2
JScript - 3.0
Internet Explorer - 4.0
Netscape - 4.0
Opera - 5.0
HTML syntax:<SCRIPT ARCHIVE="..." SRC="..."></SCRIPT>
Argument list:...A URL to reach an includable .js or .jar file

This tag attribute allows an archive file to be specified. This allows a whole collection of .js files to be shipped as a single unit. The required .js file can then be included by extracting it from the archive. If the archive is requested from the web server, it will likely persist in the cache and therefore some time is saved by collecting these archives and referring to items contained within them.

The ARCHIVE tag attribute has no use on its own in this context and you must use it with the SRC attribute.

Archives are called .jar files and are basically a zip-compressed collection of .js files. You will probably find one of the Java development environments contains all the tools you need to create these archives in a straightforward way. Actually you don't need anything more complex than a text editor and a zip compression tool.

You can do this manually if you follow these steps:

Refer to the example for script and HTML code. Create the two files test1.js and test2.js and store them in an archive called test.jar. Then create test.html with its <SCRIPT> tags to call in the files from the archive. When you run it, you can see both functions are called during the document.write() methods.

Example code:

   // Save this into file test1.js

   function test1()

   {

      return "Test 1";

   }

   -------------------------------------------------------------

   // Save this into file test2.js

   function test2()

   {

      return "Test 2";

   }

   -------------------------------------------------------------

   <!-- Save this as file test.html -->

   <HTML>

   <HEAD>

   <SCRIPT ARCHIVE="./test.jar" SRC="test1.js"></SCRIPT>

   <SCRIPT ARCHIVE="./test.jar" SRC="test2.js"></SCRIPT>

   </HEAD>

   <BODY>

   <SCRIPT>

   document.write(test1());

   document.write("<BR>");

   document.write(test2());

   document.write("<BR>");

   </SCRIPT>

   </BODY>

   </HTML>

See also:.jar, .js, <SCRIPT SRC="...">, <SCRIPT>, Adding JavaScript to HTML, File extensions, Inline script, MIME types, Security policy