JavaScript: Ensure that `$baseFiles` are loaded first if minified

This commit is contained in:
Johannes Meyer 2021-03-03 08:42:48 +01:00
parent b4531b6b45
commit 59e6ec4035
1 changed files with 6 additions and 3 deletions

View File

@ -153,8 +153,9 @@ class JavaScript
$out .= ';' . ltrim(trim(file_get_contents($file)), ';') . "\n";
}
$baseJs = '';
foreach ($baseFiles as $file) {
$js .= file_get_contents($file) . "\n\n\n";
$baseJs .= file_get_contents($file) . "\n\n\n";
}
if (! $forIe11) {
@ -202,9 +203,11 @@ class JavaScript
if ($minified) {
require_once 'JShrink/Minifier.php';
$out .= Minifier::minify($js, array('flaggedComments' => false));
$out .= Minifier::minify($js, ['flaggedComments' => false]);
$baseOut = Minifier::minify($baseJs, ['flaggedComments' => false]);
$out = ';' . ltrim($baseOut, ';') . "\n" . $out;
} else {
$out .= $js;
$out = $baseJs . $out . $js;
}
$cache->store($cacheFile, $out);