Compress JS
This commit is contained in:
parent
caa9f490af
commit
e767663f65
|
@ -9,7 +9,7 @@ if ($_GET["file"] == "favicon.ico") {
|
|||
echo lzw_decompress("compile_file('../adminer/static/default.css', 'minify_css');");
|
||||
} elseif ($_GET["file"] == "functions.js") {
|
||||
header("Content-Type: text/javascript; charset=utf-8");
|
||||
?>compile_file('../adminer/static/functions.js', 'jsShrink');compile_file('static/editing.js', 'jsShrink');<?php
|
||||
echo lzw_decompress("compile_file('../adminer/static/functions.js;static/editing.js', 'minify_js');");
|
||||
} else {
|
||||
header("Content-Type: image/gif");
|
||||
switch ($_GET["file"]) {
|
||||
|
|
19
compile.php
19
compile.php
|
@ -4,12 +4,6 @@ error_reporting(6135); // errors and warnings
|
|||
include dirname(__FILE__) . "/adminer/include/version.inc.php";
|
||||
include dirname(__FILE__) . "/externals/JsShrink/jsShrink.php";
|
||||
|
||||
if (!function_exists('jsShrink')) {
|
||||
function jsShrink($code) {
|
||||
return $code;
|
||||
}
|
||||
}
|
||||
|
||||
function add_apo_slashes($s) {
|
||||
return addcslashes($s, "\\'");
|
||||
}
|
||||
|
@ -257,9 +251,20 @@ function minify_css($file) {
|
|||
return add_quo_slashes(lzw_compress(preg_replace('~\\s*([:;{},])\\s*~', '\\1', preg_replace('~/\\*.*\\*/~sU', '', $file))));
|
||||
}
|
||||
|
||||
function minify_js($file) {
|
||||
if (function_exists('jsShrink')) {
|
||||
$file = jsShrink($file);
|
||||
}
|
||||
return add_quo_slashes(lzw_compress($file));
|
||||
}
|
||||
|
||||
function compile_file($match) {
|
||||
global $project;
|
||||
return call_user_func($match[2], file_get_contents(dirname(__FILE__) . "/$project/$match[1]"));
|
||||
$file = "";
|
||||
foreach (explode(";", $match[1]) as $filename) {
|
||||
$file .= file_get_contents(dirname(__FILE__) . "/$project/$filename");
|
||||
}
|
||||
return call_user_func($match[2], $file);
|
||||
}
|
||||
|
||||
$driver = "";
|
||||
|
|
Loading…
Reference in a new issue