WordPress 4.4 came with lots of improved features and under the hood changes. You can now embed anything like other WordPress posts, SoundCloud content, Youtube, etc.
Take a look at this example:
I’ve just pasted another blog post URL and as you see, it should create nice embed utility / widget with all meta data and featured images below.
In order to achieve and render this widget, WordPress loads one extra JavaScript file called wp-embed.min.js
into your site’s footer with some extra alternate HTML meta
tags.
Should I keep enable WP Embed functionality? Only if:
- You would like others to embed your WordPress blog articles on their site.
- You would like to embed other site’s article on you WordPress Site.
- Live rendering of widget in Post Edit Panel.
For some cases, some users, even if they don’t need this utility, WordPress always adds some javascripts and all hooks. In this case, you may want to stop loading wp-embed.min.js
.
Currently on Crunchify we have disabled
embed functionality.
Do I need this?
Well, it depends. Most of the time you don’t need. Consider this scenario. You have 500 blog posts and you have just used this feature on just few posts. Is it worth loading wp embed script on all 500 pages. Answer is NO
.
How to stop loading wp-embed.min.js on your site?
It’s very crucial to have minimum HTTP request on your site. As a WordPress optimization goal, every blogger should be concern on how their blog loads and user behavior. More HTTP requests means more contents and hence longer page load time.
Google recently has factored page loading time into their search result page. If your site loads fast then there is a high possibility that it will appear first in Google Search page.
Simply put below content to your theme’s functions.php
file and it will stop loading wp-embed.min.js
into your site’s footer.
// Remove jQuery Migrate Script from header and Load jQuery from Google API function crunchify_stop_loading_wp_embed_and_jquery() { if (!is_admin()) { wp_deregister_script('wp-embed'); wp_deregister_script('jquery'); // Bonus: remove jquery too if it's not required } } add_action('init', 'crunchify_stop_loading_wp_embed_and_jquery');
As you see in above code, you could stop loading jquery.js
and jquery-migrate.js
file which are absolutely not required
as per my understanding.
Checkout plugin Crunchy Booster Plugin:
How to disable it?
Link: https://crunchify.com/crunchy-booster/
Just turn-on toggle for Disable WP Embed Script and you are all set. Plugin will automatically turn off loading wp-embed.min.js
Script.
Also, please add below hooks to your theme’s functions.php
file to disable all WordPress default embed functions.
// 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' ); // Don't filter oEmbed results. remove_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10 ); // Remove oEmbed discovery links. remove_action( 'wp_head', 'wp_oembed_add_discovery_links' ); // Remove oEmbed-specific JavaScript from the front-end and back-end. remove_action( 'wp_head', 'wp_oembed_add_host_js' ); // Remove all embeds rewrite rules. add_filter( 'rewrite_rules_array', 'disable_embeds_rewrites' );
Should I Disable Auto Embed Script for WordPress if I’m using WooCommerce?
Ideally you shouldn’t disable it.
Update on 06/20/2017: We have enabled auto embed script on Crunchify, as we are now using it to promote other relevant articles in post.
Update on 08/21/2017: Finally playing lot with WP Embed we have disabled it all together on Crunchify.