Disable Emojis and Embeds to Cut Requests in WordPress
WordPress loads emoji and embed scripts by default on every page, which adds extra HTTP requests and can slow down your site. Disabling these features reduces unnecessary resource loading, improving page speed and overall performance. This tutorial shows you how to disable emojis and embeds in WordPress quickly and safely.
Quick Fix: Disable Emojis and Embeds in WordPress
- Add code snippets to your theme’s
functions.php
file or a site-specific plugin. - Clear any caching plugins or server caches.
- Test your site to confirm emoji and embed scripts are no longer loading.
Why This Happens
WordPress includes built-in support for emojis and oEmbed content (like YouTube videos, Tweets, etc.) by default. This support loads JavaScript and CSS files on every page:
- Emojis: WordPress loads
wp-emoji-release.min.js
and related styles to render emojis consistently across browsers. - Embeds: WordPress loads
wp-embed.min.js
to enable embedding content from other sites and to allow your content to be embedded elsewhere.
While useful for many sites, these scripts add extra HTTP requests and increase page size, which can slow down your site, especially on mobile or slow connections.
Step-by-step: Disable Emojis and Embeds in WordPress
Follow these steps to remove emoji and embed scripts from your WordPress site:
- Access your theme’s
functions.php
file or create a site-specific plugin for custom code. - Add the following code snippet:
<?php
// Disable emojis
function disable_wp_emojicons() {
// Remove emoji scripts and 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' );
// Remove from TinyMCE editor
add_filter( 'tiny_mce_plugins', 'disable_emojicons_tinymce' );
// Remove emoji CDN hostname from DNS prefetching hints
add_filter( 'emoji_svg_url', '__return_false' );
}
add_action( 'init', 'disable_wp_emojicons' );
function disable_emojicons_tinymce( $plugins ) {
if ( is_array( $plugins ) ) {
return array_diff( $plugins, array( 'wpemoji' ) );
}
return array();
}
// Disable embeds
function disable_wp_embeds() {
// Remove the REST API endpoint
remove_action( 'rest_api_init', 'wp_oembed_register_route' );
// Turn off oEmbed auto discovery
add_filter( 'embed_oembed_discover', '__return_false' );
// Remove oEmbed-specific JavaScript from front-end and back-end
remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
remove_action( 'wp_head', 'wp_oembed_add_host_js' );
// Remove TinyMCE embed plugin
add_filter( 'tiny_mce_plugins', 'disable_embeds_tinymce' );
// Remove oEmbed result caching
remove_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10 );
}
add_action( 'init', 'disable_wp_embeds' );
function disable_embeds_tinymce( $plugins ) {
if ( is_array( $plugins ) ) {
return array_diff( $plugins, array( 'wpembed' ) );
}
return array();
}
?>
- Save the file and upload it back to your server (if editing locally).
- Clear all caches: If you use caching plugins (e.g., WP Super Cache, W3 Total Cache) or server-level caching, clear those caches to see the changes immediately.
- Verify changes: Use your browser’s developer tools (Network tab) to confirm that
wp-emoji-release.min.js
andwp-embed.min.js
are no longer loaded.
Common Pitfalls
- Editing the wrong file: Always back up your
functions.php
file before editing. Use a child theme or a site-specific plugin to avoid losing changes during theme updates. - Caching issues: Changes might not appear immediately if caching plugins or server caches are active. Clear all caches after applying the code.
- Plugin conflicts: Some plugins may enqueue emoji or embed scripts independently. You may need to check plugin settings or contact plugin authors.
- Impact on embeds: Disabling embeds means WordPress won’t automatically convert URLs into embedded content. Use this only if you don’t rely on oEmbed functionality.
Works on
Environment | Compatibility |
---|---|
Web Servers | Apache, Nginx, LiteSpeed, IIS |
Control Panels | cPanel, Plesk, DirectAdmin |
WordPress Versions | 4.2 and later (all modern versions) |
PHP Versions | PHP 5.6 and later |
FAQ
- Q1: Will disabling emojis break my site’s content?
- A1: No, disabling emojis only stops WordPress from loading extra emoji scripts. Emojis will still display using native browser support but may look different on older browsers.
- Q2: Can I disable only emojis or only embeds?
- A2: Yes. You can remove either the emoji or embed code blocks separately from your
functions.php
file if you want to disable one but keep the other. - Q3: Will disabling embeds affect Gutenberg blocks?
- A3: Yes, disabling embeds removes automatic embed discovery and some embed-related blocks. If you rely heavily on Gutenberg embeds, consider leaving this enabled.
- Q4: Is there a plugin to disable emojis and embeds?
- A4: Yes, plugins like “Disable Emojis