Categories
Javascript Porter

Javascript Porter Ver 1.0

Ver 1.0(Source Code

This program gathers and sends multiple Javascript files on demand, which benefits webpage loading speed in the way of avoiding unnecessary requests and reduces the amount of Script tags on pages.

Instructions

This program search under the preset folder (JSFILEFOLDER) for requested files and send them in order.
This program accepts 3 arguments: l(link list), duplicate and compress.

Arguments:

  • link list

    A list of names of Javascript files needed to be gathered. Do not include file extension (.js), separate with commas.

  • duplicate

    Allow duplication or not (i.e. when the request is “A,B,A”, if duplication is not allowed, the last duplicated A will be ignored). Acceptable values are true | yes | false | no, default is no.

  • compress

    Level of compression. Add 1 to remove comment blocks; add 2 to remove comment lines; add 4 to remove indents; add 8 to remove line breakers. i.e. if need to remove all comments, use value 3 (Add 1 and 2). Default value is 0 (no compression).

Request Example

js.php?l=jquery-latest,yui-latest&duplicate=true&compress=15

jquery-latest.js and yui-latest.js are requested, allowing duplication, at compression level of 15.

Known Issues

  • A simple compression function is used which may cause unexpected damage to the document causing the whole script file to fail. It is recommended not to use the compression feature until this issue is fixed.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.