PHP snippet · Performance
Disable oEmbed discovery and the embed script
Stops your site advertising itself as embeddable and drops wp-embed.min.js from every page. Pasting YouTube and Vimeo links still works.
About this php snippet
WordPress ships an oEmbed layer so that other sites can embed your posts, and it loads a script on every page to resize those embeds. Most sites never use either half.
Note what this does not touch. Pasting a YouTube or Vimeo URL into a post still turns into a player, exactly as before. This only turns off your site advertising itself as embeddable, and the front-end script that goes with it.
What it does
- Removes the oEmbed discovery links from the page head
- Removes the oEmbed host JavaScript and dequeues wp-embed.min.js
- Unregisters the oEmbed REST route
- Stops WordPress fetching an unknown URL just to sniff it for oEmbed support
Good to know
- Known providers such as YouTube, Vimeo, and X are unaffected, because they are matched from a built-in list rather than by fetching the page
- Core registers the discovery links twice, at two different priorities, so the one-line version of this snippet you find on most blogs removes one copy and leaves the other still printing. This removes both, which is why it actually works.
- The one reason to leave it alone is if other WordPress sites embed your posts and you want them to keep finding the endpoint
- A rare self-hosted provider that relied on discovery will no longer auto-embed. Paste an iframe for those.



