Defer Loading comment-reply.min.js in WP

This is one way to defer the WordPress core comment-reply script, which is “comment-reply.min.js”. The following PHP function will add the “defer” attribute to the script tag for “comment-reply.min.js”.

function my_defer_scripts($tag, $handle, $src) {
	if ('comment-reply' == $handle) return "<script type='text/javascript' defer src='$src'></script>";
   return $tag;
} 
add_filter('script_loader_tag', 'my_defer_scripts', 10, 3);

See more:

By

We've One Response

Questions and Comments are Welcome

Your email address will not be published. All comments will be moderated.

Please wrap code in "code" bracket tags like this:

[code]

YOUR CODE HERE 

[/code]