Request Protocol for Javascript Porter ver 2.1

js.php?l=[linklist]
[&(compress|c)=(yes|true|no|false)]
[&(noheader|nh)=(yes|true|no|false)]

linklist = {libName}[pluginList],{libName}[pluginList],{libName}[pluginList]…

pluginList = {pluginName},{pluginName},{pluginName}…

(case insensitive)

Requesting a library (e.g. jQuery)

js.php?l=jquery

Requesting a library with specific version (e.g. jQuery ver 1.8.0)

js.php?l=jquery-1.8.0

(use hyphen to connect lib name with version. use dots to connect subversions)

Requesting a library with plugins (e.g. jQuery with UI effects core)

js.php?l=jquery[ui_effects_core]

(use square bracket to quote plugin names, separate names with commas)

Javascript Porter Ver 2.0

Source Code

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.

  • noheader

    disable header. 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&noheader=true

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

Change Log

  • Now supports file inclusion, which implements “file dependency” functionality.
    Add single-line inclusion commands to include necessary files. Its syntax is:

    //#include <filename>
    //#include_once <filename>

    filename is the name of the Javascript to be included, without extension .js.
    When using “#include_once”, the file will only be included when that file has not yet been included before.

    If loading file A, B and C, while A and B both need to include D, when processing the “#include_once” command in file B, D will not be included again.

    The inclusion command is find recuisively; if the file being included needs to include other files, those file will be loaded first.
    If any file that is need by one file fails to be loaded, either not existing or unreadable, the whole file is considered failing to be loaded.

  • Change the header to console commands.
  • Added a switch to disable header.

Known Issues

  • It is not recommended using pending in-line comments. In-line comments should take their own lines. Otherwise do not use compression.

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.