What does wp-embed.min.js do in WordPress 4.4?

Question

  1. What does the wp-embed.min.js file do? I noticed it is added to the end of my blog page footer.
  2. How can I get rid of it?

Effort

After some googling and I found Embeds on the Codex. Why does WordPress think I want to add videos, etc. to my page by default?

Environment

WordPress 4.4

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

What is it?

It is responsible for converting links into embed frames.

For example you can paste a Youtube video link into the editor content section and the Youtube embed will be generated for you when your page is viewed.

More information on WordPress Documentation

How to get rid of it?

I could finally get rid of that using this:

function my_deregister_scripts(){
  wp_deregister_script( 'wp-embed' );
}
add_action( 'wp_footer', 'my_deregister_scripts' );

Method 2

I arrived at this thread with the same question: What does the wp-embed.min.js file do? None of the current answers accurately address this question.

Firstly, I am fairly certain that embed.min.js does not relate to embedding oEmbed content from other providers: Vimeo, YouTube etc. You can remove embed.min.js and those embeds will continue to function.

It relates specifically to embeding WordPress posts from other people’s blogs/websites. Embedding WordPress posts inside WordPress posts: so meta! This feature was introduced in WordPress 4.4.

Disabling embed.min.js will stop that feature from working on your site.

You can test this easily: Paste the URL of someone else’s WordPress post into one of your own posts. WP should convert that URL into an embedded widget. When you view your post on the front-end you will notice that your markup contains a blockquote and an iframe. The blockquote is a text-only link to the blog post you embedded, while the source of the iFrame is the blog post’s URL with /embed/ appended: its oEmbed endpoint.

embed.min.js hides the blockquote and reveals the iframe. It also does some other shenanigans to make the iframe play nice.

Now, try removing the embed.min.js script from your page using one of the methods described in the other answers. Reload your page and you’ll notice that the blockquote is visible but the iframe is hidden.

In short: if you want to embed other people’s WordPress posts into your own WordPress posts, leave embed.min.js alone. If you don’t care about this feature then you can safely remove it.

Method 3

Trix’s answer didn’t work out for me on WordPress 4.4.1, but I found a solution in the code of Disable Embeds WordPress plugin. Add this code (modified) in your theme’s functions.php file to remove the wp-embed.min.js file from the frontend completely:

add_action( 'init', function() {

    // Remove the REST API endpoint.
    remove_action('rest_api_init', 'wp_oembed_register_route');

    // Turn off oEmbed auto discovery.
    // 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');
}, PHP_INT_MAX - 1 );

Method 4

I think this part is still missing.

What does the wp-embed.min.js file do? I noticed it is added to the end of my blog page footer.

The answer to this question is in the track.
https://core.trac.wordpress.org/changeset/35708

Embeds: Remove & characters from the inline embed JS.

Older versions of WordPress will convert those & characters to &, which makes for some non-functional JS. If folks are running an older release, let’s not make their lives more difficult than it already is.

It will also try to sniff the user agent.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x