You can find the latest version of this help at http://siams.com/demo/ahp/ahphelp.htm
Last updated: 21 Jan 2000
The simplest way of using AlgART HTML Packer is packing large HTML pages without JavaScript. It's a simple operation. Here is a precise instruction describing how You can pack HTML page by means of AHP.
<head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>New Page 1</title> </head> <body> </body> </html> |
<head> <title>AlgART HTML Packer (AHP)</title> </head> <body bgcolor="#FFE7D6"> <h1 align="center"><font color="#004080"><small>New ability:</small><br> <small>AlgART HTML Packer (AHP)</small></font></h1> . . . . . . . . . . . . . . . . . . . . . <li><small>address of the Web-site where You are going to use AHP.</small></li> </ul> </body> </html> |
<head> <title>AlgART HTML Packer (AHP)</title> </head> <body bgcolor="#FFE7D6"> </body> </html> |
This entire HTML is not to be packed by AHP and must be identical in the packed and unpacked versions of the Web page.
<head> <title>AlgART HTML Packer (AHP)</title> </head> <body bgcolor="#FFE7D6"> <script language="JavaScript"><!-- function unpackLZ(s,pF,pA,pB){if(pA==null&&pB==null){pA=0;...... function __T(){return (new Date()).getTime();} function __p(v){var t=__T();if(t-__t>500)...... var t1=__T(),t2,__n=0,__t=0,s, sp="LZ 3s ,c 0. ! ]<h1 align=\"center\"><font color=\"#004080\">......" +"ink: u <li><a tt=\"_blank\" href=\"e/1/jss34.htm\"a> (89Klipya (......" +"(U*%V%T(U%)'S+%T%R%S( f T%RFV'S%S%%W()+%S*'R%......" +"2J*s3i---V44-*7H$$8S$c +%T710/(8:r!^%#-/23(2 J(l+a.A!2+/6I$......"; __n=sp.length;window.status="Unpacking..."; s=unpackLZ(sp,__p,0,100); t2=__T(); window.status=window.__us=s.length+" bytes unpacked over "+...... document.writeln(s); setTimeout("window.status=window.__us",1000); //--></script> <noscript> <p>JavaScript required to view this page!</p> </noscript> </body> </html> |
where "xxxx" is the URL (absolute or relative) of the original unpacked page. Then, insert between <head> and <title> tags the following HTML:
<meta http-equiv="REFRESH" content="0;url=xxxx"> </noscript> |
This HTML forces the Web-browser to navigate to the unpacked page "xxxx"automatically if JavaScript is disabled.
The JavaScript programmers can use AlgART HTML Packer to pack any text data, in particular a large JavaScript code. More precisely, AHP builds the JavaScript fragment, which:
If You pack some JavaScript code, You will get this code as a value of the JavaScript string variable s. Then You can execute this code by the call "eval(s)". It is a good method for including large set of JavaScript functions (16-128 Kb or larger) into HTML page.
Here is an instruction describing how You can pack JavaScript code by means of AHP.
. . . . . . . . . . . . . . . . . . . . . <script language="JavaScript"><!-- function unpackLZ(s,pF,pA,pB){if(pA==null&&pB==null){pA=0;...... function __T(){return (new Date()).getTime();} function __p(v){var t=__T();if(t-__t>500)...... var t1= __T(),t2,__n=0,__t=0,s, sp="LZ /x 5! 68 #@R/* Some large JavaScript */\r\n\r\nfunction ms......" +"222222222222222222222222222222222222233333333333333333333......" +"8R0R8R0R8R0R8R0R8R0R8R0R8R0R8R0R8R0R8R0R8R0R8R0R8......" +"8R0R8R0R8R0R8R0R8R%'Y!V'!V4T'w!Y1+X$SD ^ C C H d 5 n a ......" +"TZTST]TUT_TWTaTYTcT[TeT]TeT]TeT]TeT]TeT]TeT]TeT]T......"; __n=sp.length;window.status="Unpacking..."; s= unpackLZ(sp,__p,0,100); t2= __T(); window.status= window.__us=s.length+" bytes unpacked over "+...... setTimeout("window.status=window.__us",1000); /*** *** (Please remove this comment from the resulting HTML page) *** *** Now the JavaScript variable "s" *** If this text is a JavaScript code, *** eval(s); ***/ //--></script> <noscript> <p>JavaScript required to view this page!</p> </noscript> |
The call "eval(s)" will work so as if You put the source unpacked JavaScript code instead it.
You can place the resulting packed JavaScript text not only in an HTML page, but also in a JS-file - the JavaScript file which is attached by the tag <script language="JavaScript" src="xxxx.js"></script>. In this case, please copy only the content of the <script...> tag into the JS-file.
You can choose Lempel-Ziv (LZ), Huffman or both packing algorithms.
Usually it's best to use only LZ algorithm: it gives the maximal unpacking speed and enough good compression ratio. It is the default setting.
You can increase the compression ratio by choosing both LZ and Huffman algorithms. It can be recommended if You pack large HTML document (50-100K or more), or if You design Web pages for very slow Internet connection. When packing small HTML pages, choosing both LZ and Huffman algorithms can reduce the compression ratio, because of the added JavaScript code of Huffman unpacking algorithm.
The case "Use only Huffman algorithm" can be useful in special cases when You need to pack the text, mainly, consisting of a very small set of characters (for example, only digits).
The mode "7.5 bits/character" gives better compression ratio than "6.5 bits/character". However, there is some risk that the packed page will be not viewable in some browsers with some character sets. Therefore, You have to test the result of packing at the target Web-server and all popular browsers. If it doesn't work, please try to select character set of your Web-document:
<meta http-equiv="Content-Type" content="text/html; charset=XXXX"> . . . . . . . . . . . . . . . . . . . . . </head> |
The following character sets work good under Windows platform: ISO-8859-1 (Western), Windows-1250 (Central European), Windows-1251 (Cyrillic), KOI8-R (Cyrillic), ISO-8859-5 (Cyrillic), Windows-1257 (Baltic), Windows-1253 (Greek), ISO-8859-7 (Greek), ISO-8859-9 (Turkish).
The mode "6.5 bits/character" is safe, but gives the worse compression ratio.
AHP always returns some JavaScript code as a result of packing. This JavaScript
consists of 3 parts:
If You use AHP for packing many Web-pages, there are no reasons to include the unpacking functions into all pages. Instead, You can create the JavaScript include-file unpack.js, which contains these functions, and attach it to all packed pages:
. . . . . . . . . . . . . . . . . . . . . <script language="JavaScript" src="xxxx/unpack.js"></script> <!-- here xxxx is the path to the file unpack.js in your Web-site --> </head> |
Then You can instruct AHP that it isn't needed to include unpacking functions in the result of packing. To do it, please clear the flag "Add self-extraction functions" in AHP settings.
How to create the file unpack.js? Please:
Attention! The set of required unpacking functions depends on some AHP settings: "Packing algorithms", "6.5 / 7.5 bits per character", "Compatible with Netscape 3.0". So, if You pack different pages with different settings, You must include the maximal set of unpacking functions in the JavaScript include-file unpack.js. To obtain the maximal set of unpacking functions, You must perform the packing (the step 1) with following packing options:
Packing algorithm: 6.5 / 7.5 bits per character: Compatible with Netscape 3.0: |
Use LZ and Huffman algorithms 7.5 bits per character the flag is set. |
You also can clear the flag "Add self-extraction functions" in the following situation. Let's suppose that You place several packed HTML or JavaScript blocks into the same target page. Let's also suppose that all these blocks are packed with the same AHP settings. Then You can clear this flag when packing all HTML/JavaScript blocks except the first block, because the unpacking functions defined in the first block will be available for all other blocks.
The mode "Pack HTML page" provides the simplest way to pack HTML page. AHP builds a packed HTML fragment which is equivalent to the source HTML text.
The mode "Pack plain text for JavaScript" allows You to pack any text. AHP will build the JavaScript fragment which unpacks the packed data and assigns the unpacked text to the JavaScript variable s. For example, You can use this mode to pack your JavaScript code: in this case, You must call "eval(s)" after unpacking. See above the part "How to Pack the JavaScript Code".
In the mode "Pack HTML page", AHP checks the correctness of the source unpacked text: it must be an HTML content of the <body...> tag, or a part of this content. In the mode "Pack plain text for JavaScript", AHP doesn't check the text.
If this flag is set, then HTML comments <!--...--> will be automatically removed from the text before packing. We recommend using this ability always: some browsers can have problems while unpacking HTML containing comments.
HTML comments are not removed from <script>...</script> and <style>...</style> blocks, where the comment tags <!-- and --> are placed for compatibility with old browsers and are needless in modern ones. Instead, the comment tags <!-- and --> are removed from these blocks.
Netscape Navigator 3.0 sometimes generates JavaScript errors for HTML pages
packed by AHP, if the unpacked HTML text contains some non-latin characters or if You use
the mode "7.5 bits/character". Please set the flag
"compatible with Netscape 3.0" to avoid this
problem. This flag is never needed if You use the mode "6.5 bits/character" and your source HTML
contains only standard latin characters, digits and symbols
The flag "compatible with Netscape 3.0" increases the size of the packed text by 1K.
(It is used only if the flag "compatible with Netscape 3.0" is set.)
You can insert more than 1 packed block into the packed page between <body...> and </body> tags. It can be useful, for example, for packing HTML which contains >30000 characters, when You run AHP under Netscape Navigator - see "Restrictions", 1.
If You insert several packed blocks into one HTML-page, and the flag "compatible with Netscape 3.0" is set, then You are to set unique block identifier for each block. Otherwise, the page will not be unpacked.