i have many Wordpress posts with over 200 comments, so i need to improve the speed of these posts.
In particolar, i want to improve PageSpeed Insights score, because now it reports "Avoid an excessive DOM size", caused by comments.
I try the plugin Lazy load for comments, but the score on PageSpeed Insights doesn't improve. With this plugin, Googlebot see all the same with all comments (and it's good for SEO), but the score on PageSpeed Insights is still the same.
So other solution is to active ‘Break comments into pages’ option in Wordpress. In this case, the comments are splits in many pages with pagination. I have Yoast SEO plugin, so for every page generated by pagination, like "comment-page-1", etc.., there is rel="canonical", but there is also index. Infact, this plugin has disabled the option for noindex pagination (source).
In my niche, old comments are worthless and are not important to users who visit the post today. Also i don't want to risk showing the pagination of comments in the SERP.
So i try noindex the pagination comments with this snippet for functions.php, but it works only for all URLs with "/page/" in the url (source):
add_filter("wpseo_robots", function($robots) {
if (is_paged() && is_archive()) {
return 'noindex,follow';
} else {
return $robots;
}
});
The question is: what is the best way for manage many comments in Wordpress and improve PageSpeed Insights score, destroyed by too many comments?