cache minified js files
This commit is contained in:
parent
107997e6cb
commit
c670a80ddd
|
@ -3907,4 +3907,32 @@
|
||||||
return in_array($interface, class_implements($class));
|
return in_array($interface, class_implements($class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_minified_js($files) {
|
||||||
|
require_once 'lib/jshrink/Minifier.php';
|
||||||
|
|
||||||
|
$rv = '';
|
||||||
|
|
||||||
|
foreach ($files as $js) {
|
||||||
|
if (!isset($_GET['debug'])) {
|
||||||
|
$cached_file = CACHE_DIR . "/js/$js.js";
|
||||||
|
|
||||||
|
if (file_exists($cached_file) &&
|
||||||
|
is_readable($cached_file) &&
|
||||||
|
filemtime($cached_file) >= filemtime("js/$js.js")) {
|
||||||
|
|
||||||
|
$rv .= file_get_contents($cached_file);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$minified = JShrink\Minifier::minify(file_get_contents("js/$js.js"));
|
||||||
|
file_put_contents($cached_file, $minified);
|
||||||
|
$rv .= $minified;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$rv .= file_get_contents("js/$js.js");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rv;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -36,6 +36,10 @@
|
||||||
array_push($errors, "Data export cache is not writable (chmod -R 777 ".CACHE_DIR."/export)");
|
array_push($errors, "Data export cache is not writable (chmod -R 777 ".CACHE_DIR."/export)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!is_writable(CACHE_DIR . "/js")) {
|
||||||
|
array_push($errors, "Javascript cache is not writable (chmod -R 777 ".CACHE_DIR."/js)");
|
||||||
|
}
|
||||||
|
|
||||||
if (GENERATED_CONFIG_CHECK != EXPECTED_CONFIG_VERSION) {
|
if (GENERATED_CONFIG_CHECK != EXPECTED_CONFIG_VERSION) {
|
||||||
array_push($errors,
|
array_push($errors,
|
||||||
"Configuration option checker sanity_config.php is outdated, please recreate it using ./utils/regen_config_checks.sh");
|
"Configuration option checker sanity_config.php is outdated, please recreate it using ./utils/regen_config_checks.sh");
|
||||||
|
|
10
index.php
10
index.php
|
@ -95,13 +95,9 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (array("tt-rss", "functions", "feedlist", "viewfeed", "FeedTree") as $js) {
|
print get_minified_js(array("tt-rss",
|
||||||
if (!isset($_GET['debug'])) {
|
"functions", "feedlist", "viewfeed", "FeedTree"));
|
||||||
echo JShrink\Minifier::minify(file_get_contents("js/$js.js"));
|
|
||||||
} else {
|
|
||||||
echo file_get_contents("js/$js.js");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -54,13 +54,8 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (array("functions", "deprecated", "prefs") as $js) {
|
print get_minified_js(array("functions", "deprecated", "prefs"));
|
||||||
if (!isset($_GET['debug'])) {
|
|
||||||
echo JShrink\Minifier::minify(file_get_contents("js/$js.js"));
|
|
||||||
} else {
|
|
||||||
echo file_get_contents("js/$js.js");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue