Support » Plugins » Hacks » How to disable auto wordpress emmed script

  • Resolved ionurboz


    How to remove this script in the wp-footer:


    wp_deregister_script( ‘wp-embed.min.js’ );
    wp_deregister_script( ‘wp-embed’ );
    wp_deregister_script( ’embed’ );

    Do not work -.-

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter ionurboz



    I am lost it: 'init'

    work now, ggwp 🙂

    Geoffrey Shilling


    Volunteer Moderator

    There is a plugin that was mentioned in the Make WordPress Core blog for doing this, though I haven’t used it myself:

    Blog post about embeds: New Embeds Feature in WordPress 4.4

    I hope this helps.

    I finally 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:

    function disable_embeds_init() {
        // 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');
    add_action('init', 'disable_embeds_init', 9999);

    I am a front end developer and since extra plugins is something I want to avoid the solution of Nadeem did the trick. Nicely done!

    Thank you.

    thanks for the code nadeem khan, it worked like a charm for wordpress 4.5.2

    Will this remove the youtube, dailymotion etc. also? if yes then I only want to remove the other websites embed not videos websites.

    Moderator bcworkz


    Yes, all oEmbed functionality is removed with the above code.

    To selectively allow oEmbed, hook the ‘pre_oembed_result’ filter. The post content URL that is intended to be replaced by oEmbed content is passed as the second parameter. If it’s to a known video website you want to support, return null, the oEmbed process will proceed. If you want to prevent oEmbed replacement, return the passed URL instead, doing so will short circuit the entire oEmbed process.

    tronix-ex, FYI, it’s OK to start your own topic in these forums, even when related to another topic (just link to it). As things stand now, your post is buried several pages back in the topics listing and few people will ever see it. New topics show up at the top of the first page 😉

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to disable auto wordpress emmed script’ is closed to new replies.