2017 © Pedro Peláez
 

library jsxs

A Javascript compressor based on preg written in PHP.

image

xxorax/jsxs

A Javascript compressor based on preg written in PHP.

  • Friday, July 4, 2014
  • by xxorax
  • Repository
  • 1 Watchers
  • 4 Stars
  • 191 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 1 Versions
  • 16 % Grown

The README.md

JSXS

Another Javascript compressor, written in PHP., (*1)

Test online at http://www.xorax.info/labs/jsxs/, (*2)

JSXS is in BETA test since 1 april 2009. Its possible the output compressed code not be a comptatible javascript code. Your browser can return a syntax error after the evaluation of it., (*3)

Requirement

JSXS requires a minimum of php 5.1.0 . works on all plateforms., (*4)

Usage

See example file., (*5)

Options

  • compatibility : add semi-colons at the end of block (like function, object...) if necessary. Currently, works only if shrink option is actived.
  • reduce : removes blank spaces and comments.
  • shrink : reduces the names of variables to shorter.
  • concatString : all strings concatenated with the operator of addition are merged.

Features

  • adding semicolumn if necessary : In javascript language, the end of line can be interpreted as a semicolumn, so your code without blankspace is probably wrong. This feature adds semicolumns for prevent syntax error., (*6)

  • remove multiple and unused semicolumn : Multiple ending semicolumn, and semicolumn before ending block are removed, except in for statements., (*7)

  • remove blankspace and endline : simple and usefull.
  • reduce variable names : The names of variable in non-global context are reduced to the smallest possible name, with none conflict. It's the same with function names.
  • concat string : Two string separated by + can be concatened.

Example

Uncompressed :, (*8)

``` javascript function test (arg1) { var func = function (arg1) { return arg1+2; } return 'your value' + ' : ' + arg1 + func(arg1); }, (*9)


Compressed : ``` javascript function test(b){var c=function(a){return a+2};return'your value : '+b+c(b)}

Result explained:, (*10)

  • removed white space.
  • concatened string : 'your value' + ' : ' => 'your value : '.
  • reduced variable names : arg1 => b, func => c, arg1 => a.
  • removed semicolumn : ...func(arg1); => ...c(b).
  • adding semicolumn for compatibility "} return 'your val..." => "};return'your val...".

The Versions

04/07 2014

dev-master

9999999-dev http://www.xorax.info/labs/jsxs/

A Javascript compressor based on preg written in PHP.

  Sources   Download

MIT GPL-3.0

The Requires

  • php >=5.1.0