PHP Classes

PHP JavaScript Minifier: Optimize JavaScript by removing unnecessary code

Recommend this page to a friend!
  Info   View files Example   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 82 All time: 10,022 This week: 88Up
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: 4 packages by
Country: Italy Italy
Age: 42
All time rank: 4140167 in Italy Italy
Week rank: 346 Up17 in Italy Italy Up
Innovation award
Innovation award
Nominee: 1x

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  
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  /  lib  
File Role Description
  Plain text file Minifier.php Class Class source

  Files folder image Files  /  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

 Version Control Unique User Downloads Download Rankings  
 100%
Total:82
This week:0
All time:10,022
This week:88Up