Remove the oEmbed overhead WordPress loads by default
Every WordPress page loads a small JavaScript file called wp-embed.js and advertises oEmbed discovery links in the head — whether or not you have ever embedded anything.
Toggle what you want removed above and copy the snippet. It runs in your browser; nothing is uploaded.
What WordPress adds, and what removing it saves
| Feature | What it does | Cost |
|---|---|---|
wp-embed.js | Lets other sites embed your posts in an iframe, and resizes embedded iframes on your pages | An extra HTTP request on every page load, roughly 1.5 KB |
| Discovery links | Two <link rel="alternate"> tags telling other sites how to embed your content | Head bloat; no benefit unless people embed you |
| Embed rewrite rules | Adds an /embed/ URL to every post | Extra rewrite rules, and an extra crawlable URL per post |
Be realistic about the scale: this is a small win, not a transformation. One request and a couple of head tags will not change your Core Web Vitals on their own. It is worth doing because it costs nothing, not because it is dramatic.
What you lose — read before applying
- Other sites can no longer embed your posts. If bloggers quote you by pasting your URL, that turns into a plain link instead of a rich card. For a publisher chasing reach, that is a real cost.
- Removing all providers breaks your own embeds. Unregistering providers means pasting a YouTube or X URL no longer produces a player — it stays a bare link. Existing posts change appearance too.
- Iframe auto-resizing stops. If you embed other WordPress sites, those iframes may render at the wrong height.
The safe default for most sites: disable the discovery links and wp-embed.js, but keep providers registered so your own embeds still work.
Applying the snippet
- Put it in a site-specific plugin, not
functions.php. Theme code disappears when the theme changes, and this is site behaviour rather than presentation. - Save permalinks once if you removed the rewrite rules, so the
/embed/URLs are cleared from the cache. - Purge every cache layer — page cache, then host cache, then CDN. Until you do, you will still see the old markup and conclude the snippet failed.
- Check the page source for
wp-embed. Absent means it worked. Then open a post containing a YouTube embed and confirm it still plays.
Related tools
- wp-config.php Generator
Enable safe debug logging while testing snippets.
- Server Log Analyzer
Read the PHP error if a pasted snippet takes the site down.
Frequently asked questions
Will disabling embeds break my YouTube videos?
Only if you unregister the embed providers. Removing wp-embed.js and the discovery links leaves your own embeds working normally - those options only stop other people embedding your posts. Unregistering all providers is the aggressive option: paste a YouTube URL afterwards and you get a plain link instead of a player, and existing posts change too.
How much speed does this actually gain?
One fewer HTTP request of roughly 1.5 KB, plus two tags out of the head. That is a small, genuine improvement, not a fix for a slow site. If your pages are slow, the cause is far more likely to be large images, render-blocking CSS, heavy plugins, or slow server response. Do this because it is free, not because it will move your scores.
Where should I put the snippet?
In a small site-specific plugin rather than the theme's functions.php. This is site behaviour, not presentation, so it should not vanish when the theme is switched. If you must use functions.php, use a child theme so a parent theme update cannot overwrite it.
Why is wp-embed.js still loading after I applied the snippet?
Nearly always caching. A page cache, optimisation plugin, or CDN is serving the HTML generated before the change. Purge each layer in order - plugin cache, host cache, then CDN - and check again in a private window. If it still appears, another plugin may be re-enqueuing it, so test with plugins disabled to find the source.
Do I need to flush permalinks afterwards?
Only if you removed the embed rewrite rules. Those rules are cached, so the /embed/ URLs keep responding until the cache is regenerated. Visit Settings then Permalinks and press Save once - no settings need changing. If you only removed the script and discovery links, no flush is needed.
Maintained and reviewed
Last reviewed 2026-07-21. Reflects current WordPress oEmbed behaviour, including discovery links, the embed script, and embed rewrite rules.