File: /var/www/html/wp-content/mu-plugins/performance-fixes.php
<?php
// Performance fixes - removes Google Fonts and disables WC cart fragments
// 1. Remove Google Fonts (render-blocking external resource)
add_action('wp_print_styles', function() {
global $wp_styles;
if (!isset($wp_styles->registered)) return;
foreach ($wp_styles->registered as $handle => $style) {
if (!empty($style->src) && strpos($style->src, 'fonts.googleapis.com') !== false) {
wp_deregister_style($handle);
wp_dequeue_style($handle);
}
}
}, 100);
// 2. Disable WC cart fragments on non-cart pages (heavy blocking AJAX)
add_action('wp_enqueue_scripts', function() {
$is_cart = function_exists('is_cart') ? is_cart() : false;
$is_checkout = function_exists('is_checkout') ? is_checkout() : false;
if (!$is_cart && !$is_checkout) {
wp_dequeue_script('wc-cart-fragments');
wp_deregister_script('wc-cart-fragments');
}
}, 99);
// 3. Disable emoji scripts
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');