For the performance improvements, you need to pay attention to each part of the website. Even if optimization of one element “unweights” the resource for just a few bytes, you still can have the significant result and speed improvement. In this article, we’ll teach you how to get rid of another resource hog – embed in WordPress.
What is embed and how to use it?
The oEmbed option was introduced in WordPress 4.4. The idea was pretty simple: you could add an external link (for example, a YouTube video or a Twitter post) and WordPress would display its content. It means that instead of plain links you will see the actual content – posts from the social media accounts, YouTube videos, etc. The beauty is that you don’t have to add extra code. For example, if you add a SoundCloud link to the visual editor, you’ll get something like this:
The oEmbed protocol supports not only popular social media platforms but other websites too. You can find the list of all supported resources here.
Very useful feature, isn’t it? But many websites don’t actually need it. In this case, it’s better to disable oEmbed. This way you will avoid extra HTTP-request produced for the wp-embed.min.js file. Even though this file is not heavy (<2 Kb), it loads on all pages. And this HTTP-request slows each page a bit.
How to disable embed in WordPress
There are several ways to disable embed in WordPress. Choose the method based on your skills and knowledge:
- With the plugin.
- With the code.
1.Disable embed in one click with a plugin
You can disable embed in one click with the Clearfy plugin. Go to the Performance tab and activate disable Embeds.
This plugin has a lot of other cool options. Clearfy is the free and powerful tool that can remove the extra code, fix errors, optimize pages and files, etc. If used correctly, Clearfy can increase the performance of the whole website without extra efforts. Clearfy has more than 40,000 installations and many positive reviews from users worldwide. Download the plugin here.
2.Disable embed manually with the code
If you don’t need embedded content, disable it with the special snippet:
Copy this code and add to the bottom of the functions.php file. The file is located in here: Appearance tab => Editor menu).
Important: You should be really careful when changing the code. Don’t forget to create a backup copy before changing anything! If you have a lack of tech experience and not confident in your skills, better ask developers for help or use so-called box solutions, such as plugins (see above).
How to optimize the code without disabling embed
If you use embed and want to reduce the amount of code, copy the wp-embed.min.js content to the website code. This way you’ll avoid additional HTTP-requests. However, the solution works for the files with a small amount of code.
If website optimization is important, but you’ve never worked with the code before, use the box solution – Clearfy. It has a great number of features, so you won’t have to download different plugins for different tasks. If you use videos and external materials quite often, then don’t disable embed. This feature will save you a lot of time.