Lightweight Tweaks: Disable Emojis, Embeds, and Unused Assets
WordPress comes with many features enabled by default, including emojis, embeds, and various scripts and styles. While useful in some cases, these extras can add unnecessary HTTP requests and slow down your site. By disabling what you don’t need, you can make WordPress lighter and faster. Here’s how to do it safely.
1. Disable WordPress Emojis
WordPress loads a JavaScript file (wp-emoji-release.min.js) to support emojis across browsers. If you don’t rely on it, you can safely disable it.
<?php
// Disable emojis
function my_disable_emojis() {
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' );
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_action( 'init', 'my_disable_emojis' );
?>
2. Disable WordPress Embeds
WordPress automatically allows embedding content from YouTube, Twitter (X), and other sites. This loads wp-embed.min.js, which isn’t always necessary. You can disable it:
<?php
// Disable embeds
function my_disable_embeds() {
wp_deregister_script( 'wp-embed' );
}
add_action( 'wp_footer', 'my_disable_embeds' );
?>
3. Remove jQuery Migrate (If Not Needed)
WordPress ships with jquery-migrate.js for legacy compatibility. Many modern themes and plugins don’t need it. If your site doesn’t rely on older jQuery functions, you can remove it:
<?php
// Remove jQuery Migrate
function my_remove_jquery_migrate( $scripts ) {
if ( ! is_admin() && isset( $scripts->registered['jquery'] ) ) {
$script = $scripts->registered['jquery'];
if ( $script->deps ) {
$script->deps = array_diff( $script->deps, array( 'jquery-migrate' ) );
}
}
}
add_action( 'wp_default_scripts', 'my_remove_jquery_migrate' );
?>
Note: Always test your site after disabling jQuery Migrate to ensure compatibility.
4. Remove Unused Dashicons (Frontend)
dashicons.min.css is loaded on the frontend even though it’s usually only needed for the admin area. You can prevent it from loading for non-logged-in users:
<?php
// Disable Dashicons for visitors
function my_remove_dashicons() {
if ( ! is_user_logged_in() ) {
wp_deregister_style( 'dashicons' );
}
}
add_action( 'wp_enqueue_scripts', 'my_remove_dashicons' );
?>
5. Remove Block Editor (Gutenberg) Styles (If Using Classic Editor)
If your site doesn’t use Gutenberg, you can dequeue its styles:
<?php
// Remove Gutenberg block library CSS
function my_remove_block_library_css() {
wp_dequeue_style( 'wp-block-library' );
wp_dequeue_style( 'wp-block-library-theme' );
wp_dequeue_style( 'global-styles' );
}
add_action( 'wp_enqueue_scripts', 'my_remove_block_library_css', 100 );
?>
Best Practices
- Test changes: After disabling assets, check all pages and features to ensure nothing breaks.
- Use a child theme: Place these tweaks in your child theme’s
functions.phpor a custom functionality plugin. - Measure performance: Run GTmetrix or PageSpeed Insights before and after tweaks to see the impact.
Summary
- Disable emojis to remove unnecessary scripts and styles.
- Remove embeds if you don’t need WordPress auto-embeds.
- Optionally disable jQuery Migrate for a leaner frontend.
- Unload Dashicons and Gutenberg CSS if not required.
By removing unused assets, you keep WordPress lightweight and improve your site’s performance without sacrificing essential functionality.
🎨 Want to learn more? Visit our WordPress Customization Hub for tips and advanced techniques.