I optimize WordPress sites for a living. After working on 50+ sites,
I can tell you: they all have the same 10 problems.
Here's what's slowing down your site — and the exact code to fix each one.
1. WordPress Loads Emoji Scripts on Every Page
You probably don't use WordPress emojis. Nobody does. But WordPress
loads the detection script on every single page.
// Add to functions.php or mu-plugins
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');
remove_action('admin_print_scripts', 'print_emoji_detection_script');
remove_action('admin_print_styles', 'print_emoji_styles');
Savings: ~20KB per page load.
2. jQuery Migrate Is Still Loading
WordPress loads jQuery Migrate for backwards compatibility with
plugins written in 2012. If your plugins are up to date, you
don't need it.
add_action('wp_default_scripts', function($scripts) {
if (!is_admin() && isset($scripts->registered['jquery'])) {
$scripts->registered['jquery']->deps =
array_diff($scripts->registered['jquery']->deps, ['jquery-migrate']);
}
});
Savings: ~30KB.
3. Dashicons Load on the Frontend
If you're not showing the admin bar to visitors (you shouldn't),
dashicons CSS still loads.
add_action('wp_enqueue_scripts', function() {
if (!is_user_logged_in()) {
wp_deregister_style('dashicons');
}
});
Savings: ~46KB.
4. No Image Lazy Loading (or Wrong Implementation)
WordPress has native lazy loading since 5.5. But many themes
override it or break it. The key: never lazy-load the first
image (it's usually your LCP element).
add_filter('wp_img_tag_add_loading_attr', function($value, $image, $context) {
static $count = 0;
$count++;
// Don't lazy-load first 3 images (above the fold)
return $count <= 3 ? false : 'lazy';
}, 10, 3);
5. No WebP Images
JPEG and PNG are dead. WebP is 25-35% smaller at the same quality.
If your host supports it, serve WebP automatically:
# .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{REQUEST_FILENAME} (.+)\.(jpe?g|png)$
RewriteCond %{REQUEST_FILENAME}.webp -f
RewriteRule ^(.+)\.(jpe?g|png)$ $1.$2.webp [T=image/webp,E=REQUEST_image,L]
</IfModule>
6. Render-Blocking CSS
Your entire CSS file loads before the browser shows anything.
The fix: inline critical CSS, defer the rest.
add_action('wp_head', function() {
$critical = file_get_contents(get_stylesheet_directory() . '/critical.css');
echo '<style id="critical-css">' . $critical . '</style>';
}, 1);
7. Too Many Database Queries
WordPress stores every revision of every post. A 2-year-old
site can have 10,000+ revisions eating your database.
-- Check how many revisions you have
SELECT COUNT(*) FROM wp_posts WHERE post_type = 'revision';
-- Delete all but the last 3 per post
DELETE FROM wp_posts WHERE post_type = 'revision'
AND ID NOT IN (
SELECT ID FROM (
SELECT ID FROM wp_posts WHERE post_type = 'revision'
ORDER BY post_date DESC LIMIT 3
) AS keep
);
8. No Browser Caching Headers
Without proper cache headers, browsers re-download everything
on every visit.
# .htaccess
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType text/css "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
</IfModule>
9. Gutenberg Block CSS on Non-Gutenberg Pages
Even if you use Elementor or a classic theme, WordPress loads
Gutenberg's block library CSS.
add_action('wp_enqueue_scripts', function() {
wp_dequeue_style('wp-block-library');
wp_dequeue_style('wp-block-library-theme');
wp_dequeue_style('wc-blocks-style'); // WooCommerce blocks
});
Savings: ~40KB.
10. WordPress Version Exposed
Not a speed issue, but a security one. WordPress adds its
version to every page source. Hackers love this.
remove_action('wp_head', 'wp_generator');
add_filter('the_generator', '__return_empty_string');
Results
On a typical site, applying all 10 fixes:
| Metric | Before | After |
|---|---|---|
| PageSpeed Mobile | 41 | 89 |
| Load Time | 4.2s | 1.1s |
| Total JS | 380KB | 210KB |
| Total CSS | 290KB | 180KB |
| Database Queries | 84 | 31 |
Want the Complete Toolkit?
I packaged all these fixes into drop-in PHP scripts. Upload
to mu-plugins, they activate automatically. No plugin needed.
Free source code: github.com/ehonep/wordpress-speed-optimization
Complete kit with WP Rocket config + .htaccess rules:
hoehenator.gumroad.com/l/pcrnva
Top comments (0)