Categories
WordPress

How to Remove the Embed Script from WordPress

If you’re looking to speed up your site by reducing the number of scripts that WordPress loads then this is an easy one for you.

Much like disabling the script and stylesheet for using emojis in WordPress, this little snippet will disable the script for using embeds. For those that don’t know, embeds are when rich content is pulled through from another website, such as a YouTube video or a tweet from Twitter. By pasting a link to the video or tweet into the content editor, for example, WordPress will automatically convert this into an embedded bit of content.

So if you can’t see yourself ever using that feature or just want to strip down your site to be as lean as possible (you can use embed by adding the embed code manually), then just add the following code to your function.php file and you’re good to go!

// Remove URL embedding for tweets, YouTube videos, etc

function disable_wp_embed() {
    if (!is_admin()) {
        wp_deregister_script('wp-embed');
    }
}
add_action('init', 'disable_wp_embed');

As always, let me know how you get on with this in the comments below.

Leave a Reply

Your email address will not be published. Required fields are marked *