mirror of
https://github.com/gtbu/Typesetter-5.3-p8.git
synced 2025-05-09 21:23:14 +02:00
update CombineCss
Minimizes css-files only of in the first 15 positions are less than 3 spaces
This commit is contained in:
parent
a3185d4cf8
commit
8a9b7c71bb
1 changed files with 22 additions and 14 deletions
|
@ -63,21 +63,29 @@ class CombineCSS {
|
|||
|
||||
// --- Final Minification ---
|
||||
if ($this->minify_output) {
|
||||
try {
|
||||
// Ensure cssmin class exists before calling
|
||||
if (class_exists('\cssmin')) {
|
||||
$this->final_content = \cssmin::minify($this->combined_content_raw);
|
||||
} else {
|
||||
// Should have been caught earlier, but as a fallback
|
||||
$this->final_content = $this->combined_content_raw;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
trigger_error('CombineCSS: Minification failed for ' . htmlspecialchars($file) . ': ' . $e->getMessage(), E_USER_WARNING);
|
||||
$this->final_content = $this->combined_content_raw; // Fallback to raw content on error
|
||||
try {
|
||||
if (class_exists('\cssmin')) {
|
||||
// --- Start: Check if content looks already minified ---
|
||||
$first_chunk = substr($this->combined_content_raw, 0, 15);
|
||||
$space_count = substr_count($first_chunk, ' ');
|
||||
|
||||
if ($space_count < 3) {
|
||||
$this->final_content = $this->combined_content_raw;
|
||||
} else {
|
||||
$this->final_content = \cssmin::minify($this->combined_content_raw);
|
||||
}
|
||||
} else {
|
||||
$this->final_content = $this->combined_content_raw;
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->final_content = $this->combined_content_raw;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$errorFile = isset($file) ? htmlspecialchars($file) : 'unknown source';
|
||||
trigger_error('CombineCSS: Minification failed for ' . $errorFile . ': ' . $e->getMessage(), E_USER_WARNING);
|
||||
$this->final_content = $this->combined_content_raw; // Fallback to raw content on error
|
||||
}
|
||||
} else {
|
||||
$this->final_content = $this->combined_content_raw;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue