WordPress – How to remove comment-reply.min.js from page source

By default WordPress loads a JavaScript file called comment-reply.min.js for each page load.

This will look something like

http://www.itsupportguides.com/wp-includes/js/comment-reply.min.js?ver=4.2.2

comment-reply.min.js is necessary if you are using WordPress as a blog and need the built in commenting features – but if you aren’t running a blog or are using a third-party commenting system such as Disqus it’s not necessary and can be removed.

Removing it will reduce the page load time and size marginally, but sometimes even the slightest improvement in page load time can be worth it.

The following code can be added to your themes functions.php file, it will stop the file from being inserted into your page.

If you’re not sure where to place this code I highly recommend you read How to create a WordPress plugin for your custom functions.

// DISABLE WORDPRESS COMMENTS JS

function itsg_disable_comment_js(){
    wp_deregister_script( 'comment-reply' );
}
add_action( 'init', 'itsg_disable_comment_js' );

Was this article helpful?

Related Articles