PHP Classes

PHP JavaScript Minifier: Optimize JavaScript by removing unnecessary code

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 84 All time: 10,045 This week: 66Up
Version License PHP version Categories
javascript-minifier 1.0.0Custom (specified...5PHP 5, Compression, Performance and o...
Description 

Author

This class can optimize JavaScript by removing unnecessary code.

It can take a string with JavaScript and perform several types of optimizations to to reduce the size of the resulting code.

Currently the class can remove comments, convert line breaks with to characters into just one, etc..

Picture of Luca Liscio
  Performance   Level  
Name: Luca Liscio <contact>
Classes: 5 packages by
Country: Italy Italy
Age: 42
All time rank: 4066166 in Italy Italy
Week rank: 200 Up9 in Italy Italy Up
Innovation award
Innovation award
Nominee: 2x

Example

<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
require_once 'lib/Minifier.php';
require_once
'config.php';



$js = "";
foreach(
$cfg->infiles as $file) {
    echo
"Minify: ".$file."\n";
   
$js .= \JShrink\Minifier::minify(file_get_contents("in/".$file));
}

echo
"\n\nSaving: ".$cfg->outfile."\n";
file_put_contents("out/".$cfg->outfile, $js);


Details

JavaScript-Minifier

Simple JavaScript Minifier written in PHP


  Files folder image Files (7)  
File Role Description
Files folder imagelib (1 file)
Files folder imagenbproject (2 files)
Accessible without login Plain text file config.php Conf. Configuration script
Accessible without login Plain text file index.php Example Example script
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files (7)  /  lib  
File Role Description
  Plain text file Minifier.php Class Class source

  Files folder image Files (7)  /  nbproject  
File Role Description
  Accessible without login Plain text file project.properties Data Auxiliary data
  Accessible without login Plain text file project.xml Data Auxiliary data

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:84
This week:0
All time:10,045
This week:66Up