Files
roi-theme/minify-css.php
FrankZamora c7e8f14d83 perf: Optimización PageSpeed - Score 81→97
Cambios implementados:

1. CSS Crítico (critical-bootstrap.css):
   - Agregar clases responsive d-lg-none, d-lg-block, d-lg-flex
   - Prevenir CLS en TopNotificationBar al ocultar en móvil
   - Agregar estilos para tablas y main content (CLS fix)

2. Google Analytics Diferido (adsense-placement.php):
   - GA4 ahora carga después de 3s o primera interacción
   - Reduce ~59 KiB de JavaScript bloqueante
   - TBT mejorado significativamente

3. CSS Minificado (enqueue-scripts.php):
   - Usar style.min.css y css-global-accessibility.min.css
   - Ahorro ~6 KiB en transferencia

4. Nuevo script minify-css.php para generar versiones .min.css

Resultados PageSpeed Mobile:
- Performance: 81 → 97 (+16 puntos)
- FCP: 2.8s → 1.0s (-64%)
- LCP: 3.5s → 1.3s (-63%)
- Core Web Vitals: SUPERADA

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 13:23:20 -06:00

61 lines
1.7 KiB
PHP

<?php
/**
* Simple CSS Minifier Script
* Run from command line: php minify-css.php
*/
function minify_css($css) {
// Remove comments
$css = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $css);
// Remove space after colons
$css = str_replace(': ', ':', $css);
// Remove whitespace
$css = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $css);
// Remove space before and after specific characters
$css = preg_replace('/\s*([{};,>+~])\s*/', '$1', $css);
// Remove last semicolon before closing brace
$css = str_replace(';}', '}', $css);
// Trim
$css = trim($css);
return $css;
}
$files = [
'Assets/css/css-global-accessibility.css' => 'Assets/css/css-global-accessibility.min.css',
'Assets/css/style.css' => 'Assets/css/style.min.css',
];
$base_path = __DIR__ . '/';
foreach ($files as $source => $dest) {
$source_path = $base_path . $source;
$dest_path = $base_path . $dest;
if (file_exists($source_path)) {
$css = file_get_contents($source_path);
$minified = minify_css($css);
file_put_contents($dest_path, $minified);
$original_size = strlen($css);
$minified_size = strlen($minified);
$savings = $original_size - $minified_size;
$percent = round(($savings / $original_size) * 100, 1);
echo "Minified: $source\n";
echo " Original: " . number_format($original_size) . " bytes\n";
echo " Minified: " . number_format($minified_size) . " bytes\n";
echo " Savings: " . number_format($savings) . " bytes ($percent%)\n\n";
} else {
echo "File not found: $source\n";
}
}
echo "Done!\n";