Skip to content

Commit

Permalink
^ aurora.compressCSSJS()
Browse files Browse the repository at this point in the history
  • Loading branch information
SindlaXYZ committed Jan 24, 2021
1 parent 4c3d02e commit 48efe0a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Utils/Twig/UtilityExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ public function compressCSSJS(Request $Request, string $assetType, bool $combine
*/

if ($combineAndMinify && ($onDev || !file_exists($combineAndMinifyOutputAbsPath))) {
// Load local files
if (!preg_match('/http:|https:|ftp:/', $assetWebPath)) {

$assetContent = file_get_contents($assetAbsPath);
Expand All @@ -471,11 +472,13 @@ public function compressCSSJS(Request $Request, string $assetType, bool $combine
? $serviceSanitizer->cssMinify($assetContent, $assetWebPath)
: \JShrink\Minifier::minify($assetContent, ['flaggedComments' => false]) . ';'
);
// Load external files
} else {
if ('css' == $assetType) {
$combineAndMinifyOutputContentHead .= '@import url("' . $assetWebPath . '");';
} else {
trigger_error('External JS files not supported.');
$njs = 'newScript' . substr(mt_rand(0, 999) . sha1(microtime() . mt_rand(0, 999)), 0, 6);
$combineAndMinifyOutputContent .= "var {$njs} = document.createElement('script'); {$njs}.type = 'text/javascript'; {$njs}.src = '{$assetWebPath}'; document.getElementsByTagName('head')[0].appendChild({$njs});";
}
}
}
Expand Down

0 comments on commit 48efe0a

Please sign in to comment.