Speed Up your WordPress Site!

Disable Auto Embed Scripts

How to stop loading wp-embed.min.js on your site?

It’s very crucial to have minimum HTTP request on your site. As a WordPress optimization goal, every blogger should be concern on how their blog loads and user behavior. More HTTP requests means more contents and hence longer page load time.

As you see in above code, you could stop loading jquery.js and jquery-migrate.js files which are absolutely not required as per my understanding.

// Remove jQuery Migrate Script from header and Load jQuery from Google API
function crunchify_stop_loading_wp_embed_and_jquery() {
	if (!is_admin()) {
		wp_deregister_script('jquery');  // Bonus: remove jquery too if it's not required
add_action('init', 'crunchify_stop_loading_wp_embed_and_jquery');


Also, please add below hooks to your theme’s functions.php file to disable all WordPress default embed functions.(NOT for WooCommerce Sites)

// Remove the REST API endpoint.
remove_action( 'rest_api_init', 'wp_oembed_register_route' );

// Turn off oEmbed auto discovery.
add_filter( 'embed_oembed_discover', '__return_false' );

// 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' );

// Remove all embeds rewrite rules.
add_filter( 'rewrite_rules_array', 'disable_embeds_rewrites' );