SourceForge Support This Project

JS Joiner: realtime JavaScript optimizer

Current version: 1.0
Author: Pavel Tzonkov
License: LGPLv2
Copyright ©2010 JS Joiner Project

Contents

  1. Overview
  2. Features
  3. Compatibality
  4. Demo
  5. Download
  6. Last version changelog
  7. Installation
  8. How to integrate another JavaScript parser
  9. Used 3rd party software

Overview

JS Joiner is a realtime JavaScript optimizer, you may use in your web site/application to minimize JavaScript code returned from your web server. Multiple local or external files can be loaded just like single JavaScript file - using single <script> tag (one server request). Caching system is available for faster responses - generate and save compressed JavaScript code once, until change in source files is done.

Features

Compatibality

Demo

Enter URL paths to source JavaScript files you want to parse. Please type each URL in single line:

Method:        

Script tag:


Uncompressed code:


Compressed code:

Download

  1. Zip package
  2. GZip package
  3. BZip2 package

Last version changelog

Version 1.0 - May 15, 2010

Installation

  1. Unpack and upload the package files to a directory on your site (e.g. /jsj).
  2. Make sure /jsj/jsmin/cache and /jsj/jspack/cache directories are writable for the web server.
  3. Now JS Joiner is installed and ready for use. You may parse your JavaScript files in src atribute of a <script> tag.
  4. Using JSMin method with js[] GET parameters:

    /jsj/jsmin/?js[]=unlocated.js&js[]=%2Fapp%2Flocated.js&js[]=%2Fjs_dir&js[]=http%3A%2F%2Fexternal.site.com%2Fscript.js

    Paths to source JavaScript files are defined as js[] GET parameters. It's recommended to URL-encode these parameters. The files will be parsed in order as they are defined in the URL address. This example will parse these files if they exists:

    For security resons local files with .js extension only can be parsed. By default it's valid rule for external files. There are several external files settings defined and described in /jsj/class.JSjoin.php.

    Using JavaScript Packer method with mod_rewrite URL style:

    /jsj/jspack/unlocated.js../js../app/common.js..http://external.site.com/script.js

    This example will work only if mod_rewrite Apache module is available. JavaScript Packer (jspack) method is used. The source JavaScript files are separated by .. delimiter. You may change the delimiter editing /jsj/class.JSjoin.php file.

How to integrate another JavaScript parser

Currently JS Joiner has two JavaScript parsers - JSMin and JavaScript Packer. If you want to use another parser please follow these steps:

  1. Create unique directory in JS Joiner main directory. (e.g. /jsj/new_parser).
  2. Copy there .htaccess and index.php files from other parser's directory.
  3. Create /jsj/new_parser/cache directory and change its permissions to be writable for the web server.
  4. Create /jsj/new_parser/includes directory.
  5. Create /jsj/new_parser/includes/parser.php file:
  6. <?php
    
    class parser extends JSjoin {
    
        protected function parse_file($file) {
            return self::parse_file_static($file);
        }
    
        static function parse_file_static($file) {
            $code = file_get_contents($file);
    
            // Here is the place you should to parse JavaScript code
    
            return $code;
        }
    }
    
    ?>

    If you leave this file as is, the parser will only join source JavaScript files without any compression. You may parse $code variable. If you want to use complete 3rd party parser, you should to include its source code on top of this file. See /jsj/jsmin/includes/parser.php and /jsj/jspack/includes/parser.php for examples.

Used 3rd party software