Lightweight Tweaks: Disable Emojis, Embeds, and Unused Assets
Small, surgical optimizations can shave off requests, reduce CSS/JS payloads, and make WordPress feel instantly snappier. This guide shows safe theme-agnostic ways to disable emoji scripts, oEmbed, and other front-end assets you likely don’t need—without breaking the editor or admin.
Before You Start
All snippets below are safe for functions.php (child theme) or an MU-plugin (recommended). To keep tweaks across theme switches, prefer an MU-plugin:
/* wp-content/mu-plugins/perf-tweaks.php */
<?php
/**
* Plugin Name: Performance Tweaks (Site)
* Description: Disable emojis, embeds, and unused assets.
*/
Disable Emojis (front & back)
WordPress ships an emoji detection script and styles. If you don’t rely on legacy emoji fallbacks, you can remove them safely.
add_action( 'init', function () {
// Front/admin emoji scripts & styles
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
// Email & feed filters
remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
// TinyMCE emoji plugin
add_filter( 'tiny_mce_plugins', function ( $plugins ) {
return is_array( $plugins ) ? array_diff( $plugins, [ 'wpemoji' ] ) : $plugins;
});
});
Disable oEmbed & the wp-embed Script
If you don’t need to auto-embed external URLs (YouTube, tweets, etc.), remove the oEmbed discovery and the legacy wp-embed helper.
// Stop oEmbed discovery & REST route
remove_action( 'rest_api_init', 'wp_oembed_register_route' );
add_filter( 'embed_oembed_discover', '__return_false' );
// Remove front-end oEmbed extras
remove_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10 );
remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
remove_action( 'wp_head', 'wp_oembed_add_host_js' );
// Dequeue legacy wp-embed script
add_action( 'wp_enqueue_scripts', function () {
wp_deregister_script( 'wp-embed' );
}, 100 );
Trim Block Editor CSS on the Front End
Block themes and modern classic themes enqueue several CSS layers. You can often drop some globally without breaking layouts.
Remove Block Library CSS (front end)
add_action( 'wp_enqueue_scripts', function () {
wp_dequeue_style( 'wp-block-library' ); // Core block base CSS
wp_dequeue_style( 'wp-block-library-theme' ); // Core block theme CSS
wp_dequeue_style( 'global-styles' ); // theme.json inline CSS (handles)
}, 20 );
Disable Global Styles Inline CSS
WordPress may print a large inline global-styles chunk. You can filter it out:
// WP 5.9+ global styles: prevent inline CSS
add_filter( 'should_load_separate_core_block_assets', '__return_true' ); // Split per-block CSS
add_filter( 'wp_enqueue_global_styles', '__return_false' ); // Skip global-styles enqueue
Remove Dashicons on the Front End
Dashicons are for the admin UI. If your theme doesn’t use them on the front end, dequeue:
add_action( 'wp_enqueue_scripts', function () {
if ( ! is_user_logged_in() ) {
wp_deregister_style( 'dashicons' );
}
}, 100 );
Remove Comment Reply Script (if you don’t use threaded comments)
add_action( 'init', function () {
if ( ! is_admin() ) {
wp_deregister_script( 'comment-reply' );
}
});
Opt Out of jQuery Migrate (only if you control legacy code)
If your theme/plugins don’t depend on deprecated jQuery APIs, you can drop jQuery Migrate to remove an extra JS:
add_action( 'wp_default_scripts', function ( $scripts ) {
if ( ! empty( $scripts->registered['jquery'] ) ) {
$deps = &$scripts->registered['jquery']->deps;
$scripts->remove( 'jquery-migrate' );
$deps = array_diff( $deps, [ 'jquery-migrate' ] );
}
});
Remove WLW, RSD, Shortlink, and REST Link Tags
These add extra <link> tags to <head>. Usually safe to remove on public sites.
remove_action( 'wp_head', 'rsd_link' ); // RSD
remove_action( 'wp_head', 'wlwmanifest_link' ); // WLW
remove_action( 'wp_head', 'wp_shortlink_wp_head' ); // Shortlink
remove_action( 'wp_head', 'rest_output_link_wp_head', 10 ); // REST API link
remove_action( 'template_redirect', 'rest_output_link_header', 11 );
Host-Level Hints: Preload Your LCP, Defer the Rest
<link rel="preload" as="image"
href="/path/hero-1200.jpg"
imagesrcset="/path/hero-768.jpg 768w, /path/hero-1200.jpg 1200w"
imagesizes="(max-width: 768px) 100vw, 1200px">
One-Stop “Minimal Front” Bundle
add_action( 'init', function () {
// Emojis
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
add_filter( 'tiny_mce_plugins', fn( $p ) => is_array( $p ) ? array_diff( $p, [ 'wpemoji' ] ) : $p );
// oEmbed & legacy wp-embed
remove_action( 'rest_api_init', 'wp_oembed_register_route' );
add_filter( 'embed_oembed_discover', '__return_false' );
remove_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10 );
remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
remove_action( 'wp_head', 'wp_oembed_add_host_js' );
});
add_action( 'wp_enqueue_scripts', function () {
// Drop front-end helpers
wp_deregister_script( 'wp-embed' );
if ( ! is_user_logged_in() ) {
wp_deregister_style( 'dashicons' );
}
// CSS trimming
wp_dequeue_style( 'wp-block-library-theme' );
wp_dequeue_style( 'global-styles' );
}, 100);
// Split per-block CSS, avoid big inline global-styles
add_filter( 'should_load_separate_core_block_assets', '__return_true' );
add_filter( 'wp_enqueue_global_styles', '__return_false' );
// Head cleanups
remove_action( 'wp_head', 'rsd_link' );
remove_action( 'wp_head', 'wlwmanifest_link' );
remove_action( 'wp_head', 'wp_shortlink_wp_head' );
remove_action( 'wp_head', 'rest_output_link_wp_head', 10 );
remove_action( 'template_redirect', 'rest_output_link_header', 11 );
🎨 Want to learn more? Visit our WordPress Customization Hub for tips and advanced techniques.