{"id":1607,"date":"2022-03-24T07:39:37","date_gmt":"2022-03-24T04:39:37","guid":{"rendered":"https:\/\/saedx.com\/blog\/?p=1607"},"modified":"2022-03-24T07:42:50","modified_gmt":"2022-03-24T04:42:50","slug":"how-to-disable-wp-embed-min-js-and-wp-emoji-release-min-js","status":"publish","type":"post","link":"https:\/\/saedx.com\/blog\/how-to-disable-wp-embed-min-js-and-wp-emoji-release-min-js","title":{"rendered":"How to Disable wp-embed.min.js and wp-emoji-release.min.js"},"content":{"rendered":"\n<p>Disabling WP Embeds and WP Emojis are one of a lot of WordPress performance optimizations and tweaks you can do to improve your website loading time.<\/p>\n\n\n\n<p>Firstly, let&#8217;s take a look at what is WP Embeds then WP Emojis<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>WP Embeds:<\/strong><\/h2>\n\n\n\n<p>It is responsible for converting links into embed frames like embed&nbsp;videos, images, tweets, audio, and other content into your WordPress site.<\/p>\n\n\n\n<p>wp-embed.min.js does not relate to embedding oEmbed content from other providers: Vimeo, YouTube, etc. You can remove wp-embed.min.js and those embeds will continue to function.<\/p>\n\n\n\n<p>wp-embed.min.js hides the blockquote and reveals the iframe. if removing the wp-embed.min.js script from your website using the below method then reload your page and you&#8217;ll notice that the blockquote is visible but the iframe is hidden.<\/p>\n\n\n\n<p>In this article, we will disable wp-embed.min.js and wp-emoji-release.min.js with the code method, if you are not familiar with codes check with a developer first.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Disable wp-embed.min.js<\/h2>\n\n\n\n<p>We recommend doing it if you have a child theme.<br>at <strong>child theme &gt; functions.php &gt; add a code<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function disable_embeds_code_init() {\n\n \/\/ Remove the REST API endpoint.\n remove_action( 'rest_api_init', 'wp_oembed_register_route' );\n\n \/\/ Turn off oEmbed auto discovery.\n add_filter( 'embed_oembed_discover', '__return_false' );\n\n \/\/ Don't filter oEmbed results.\n remove_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10 );\n\n \/\/ Remove oEmbed discovery links.\n remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );\n\n \/\/ Remove oEmbed-specific JavaScript from the front-end and back-end.\n remove_action( 'wp_head', 'wp_oembed_add_host_js' );\n add_filter( 'tiny_mce_plugins', 'disable_embeds_tiny_mce_plugin' );\n\n \/\/ Remove all embeds rewrite rules.\n add_filter( 'rewrite_rules_array', 'disable_embeds_rewrites' );\n\n \/\/ Remove filter of the oEmbed result before any HTTP requests are made.\n remove_filter( 'pre_oembed_result', 'wp_filter_pre_oembed_result', 10 );\n}\n\nadd_action( 'init', 'disable_embeds_code_init', 9999 );\n\nfunction disable_embeds_tiny_mce_plugin($plugins) {\n    return array_diff($plugins, array('wpembed'));\n}\n\nfunction disable_embeds_rewrites($rules) {\n    foreach($rules as $rule =&gt; $rewrite) {\n        if(false !== strpos($rewrite, 'embed=true')) {\n            unset($rules&#91;$rule]);\n        }\n    }\n    return $rules;\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>WP Emojis<\/strong><\/h2>\n\n\n\n<p>Emoji are the ideograms and smileys&nbsp;that are used in electronic messages and Web pages.&nbsp;It is unnecessary at all and adds additional load time.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Disable wp-emoji-release.min.js<\/h2>\n\n\n\n<p>at <strong>child theme &gt; functions.php &gt; add a code<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function disable_emojis() {\n remove_action( 'wp_head', 'print_emoji_detection_script', 7 );\n remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );\n remove_action( 'wp_print_styles', 'print_emoji_styles' );\n remove_action( 'admin_print_styles', 'print_emoji_styles' ); \n remove_filter( 'the_content_feed', 'wp_staticize_emoji' );\n remove_filter( 'comment_text_rss', 'wp_staticize_emoji' ); \n remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );\n add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' );\n add_filter( 'wp_resource_hints', 'disable_emojis_remove_dns_prefetch', 10, 2 );\n}\nadd_action( 'init', 'disable_emojis' );\n\n\/**\n * Filter function used to remove the tinymce emoji plugin.\n * \n * @param array $plugins \n * @return array Difference betwen the two arrays\n *\/\nfunction disable_emojis_tinymce( $plugins ) {\n if ( is_array( $plugins ) ) {\n return array_diff( $plugins, array( 'wpemoji' ) );\n } else {\n return array();\n }\n}\n\n\/**\n * Remove emoji CDN hostname from DNS prefetching hints.\n *\n * @param array $urls URLs to print for resource hints.\n * @param string $relation_type The relation type the URLs are printed for.\n * @return array Difference betwen the two arrays.\n *\/\nfunction disable_emojis_remove_dns_prefetch( $urls, $relation_type ) {\n if ( 'dns-prefetch' == $relation_type ) {\n \/** This filter is documented in wp-includes\/formatting.php *\/\n $emoji_svg_url = apply_filters( 'emoji_svg_url', 'https:\/\/s.w.org\/images\/core\/emoji\/2\/svg\/' );\n\n$urls = array_diff( $urls, array( $emoji_svg_url ) );\n }\n\nreturn $urls;\n}\n<\/code><\/pre>\n\n\n\n<p>If you don&#8217;t use a child theme or you want to add it on another way you could <strong>add it via the <a href=\"https:\/\/wordpress.org\/plugins\/code-snippets\/\" target=\"_blank\" rel=\"noreferrer noopener\">Code Snippets plugin<\/a><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Disabling WP Embeds and WP Emojis are one of a lot of WordPress performance optimizations and tweaks you can do to improve your website loading time. Firstly, let&#8217;s take a&hellip;<\/p>\n","protected":false},"author":1,"featured_media":1609,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","footnotes":""},"categories":[11],"tags":[],"jetpack_featured_media_url":"https:\/\/saedx.com\/blog\/wp-content\/uploads\/2022\/03\/saedx-blog-featured-81.jpg","jetpack_shortlink":"https:\/\/wp.me\/p3wRFx-pV","_links":{"self":[{"href":"https:\/\/saedx.com\/blog\/wp-json\/wp\/v2\/posts\/1607"}],"collection":[{"href":"https:\/\/saedx.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/saedx.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/saedx.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/saedx.com\/blog\/wp-json\/wp\/v2\/comments?post=1607"}],"version-history":[{"count":2,"href":"https:\/\/saedx.com\/blog\/wp-json\/wp\/v2\/posts\/1607\/revisions"}],"predecessor-version":[{"id":1612,"href":"https:\/\/saedx.com\/blog\/wp-json\/wp\/v2\/posts\/1607\/revisions\/1612"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/saedx.com\/blog\/wp-json\/wp\/v2\/media\/1609"}],"wp:attachment":[{"href":"https:\/\/saedx.com\/blog\/wp-json\/wp\/v2\/media?parent=1607"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/saedx.com\/blog\/wp-json\/wp\/v2\/categories?post=1607"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/saedx.com\/blog\/wp-json\/wp\/v2\/tags?post=1607"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}