Lazy Load for Comments

Plugin Banner

Lazy Load for Comments

by Joel James

Download
Description

Comments are heavy. A long thread can pull in dozens of avatars, gravatar lookups and reply scripts — all of which the browser downloads before the visitor has even reached them. Lazy Load for Comments defers all of that until the visitor either scrolls to the comments area or clicks a button.

The result: fewer HTTP requests, faster Largest Contentful Paint and a happier Lighthouse score, without changing how your comment template looks.

Version 2.0 is a complete rewrite. It uses the WordPress REST API to fetch the rendered comments on demand and works with both classic themes (comments_template()) and block themes (the core Comments block) out of the box.

Features

  • Lazy-load comments on scroll, on button click, or turn the plugin off without deactivating it.
  • Works with classic themes and block themes (the core Comments block).
  • Loads comments inline for search engine crawlers, so indexing and SEO are not affected.
  • Per-post cache of the rendered Comments block — REST renders stay fast.
  • Minimum-comment-count threshold so short threads still render inline.
  • Customisable load-button text, style and extra CSS classes.
  • Clean React settings page under Comments Lazy Load.
  • No jQuery dependency. Front-end script is vanilla JS and intentionally small.
  • Translation-ready. Hooks and filters available for further customisation.

Useful links

From the WordPress admin (recommended)

  1. Go to Plugins Add New, search for Lazy Load for Comments and click Install now.
  2. Activate the plugin.
  3. Open Comments Lazy Load and pick the load method that suits you.

Manual install

  1. Upload the lazy-load-for-comments folder to /wp-content/plugins/.
  2. Activate the plugin from the Plugins screen.
  3. Open Comments Lazy Load to configure the settings.

For the full configuration guide, see the official documentation.

  1. Loading behaviour settings.

    Loading behaviour settings.

  2. Load button settings.

    Load button settings.

  3. Cache management.

    Cache management.

Does it work with block themes?

Yes. The plugin detects whether the active theme is a block theme and either swaps the classic comments_template() output or replaces the rendered core/comments block, whichever applies.

Will it work with my caching plugin?

Yes. The placeholder rendered server-side is plain HTML, so full-page caches can cache it safely. The actual comments are fetched from a public REST endpoint, which is also cache-friendly.

How do I change the load method?

Open Comments Lazy Load and pick one of On scroll, On button click or Disabled on the Settings tab.

How do I customise the load button?

The button text, the style (inherit your theme’s style or use the plugin’s built-in style) and extra CSS classes can all be set under Load Button on the Settings tab.

Does it support comment plugins like Disqus or Jetpack Comments?

No — this plugin only handles the default WordPress comments. Third-party comment systems (Disqus, Jetpack Comments, etc.) replace the comment area entirely, so there is nothing for this plugin to lazy-load.

How do I disable lazy loading for a specific post or page?

Use the lazy_load_for_comments_can_lazy_load filter:

add_filter( 'lazy_load_for_comments_can_lazy_load', function ( $can ) {
    if ( is_page( 'contact' ) ) {
        return false;
    }
    return $can;
} );

Are comments still indexed by Google?

Yes. By default the plugin detects search-engine crawlers from the User-Agent and serves them the original (inline) comments markup, so indexing is not affected. You can turn this behaviour off on the Settings tab if you’d rather always lazy-load.

Where can I get help?

The official documentation covers most setups. For everything else, the free WordPress.org support forum is the best place to start.

Has Potential

By Emory Rowland (Emory) on February 24, 2024

But support is unresponsive.

Good, but needs some enhancements

By itsryu on February 8, 2022

It breaks the Moderation notice. The user just gets sent back to the main page and they don't know if their comment submitted or not. In my analytics, it states that there is a javascript error, so that needs to be fixed. It also breaks the built in discussion settings of breaking the comments into groups, and the feature of clicking "next" to get the next batch Other than that it works. Simple plugin without options.

Amazing plugin

By yastychef on September 27, 2021

Great plugin, works fine. I just hope it always gets updated. Keep up the great work!

Best Plugin I've ever used

By fernandroid3 on March 22, 2021

Congratulations and thank you very much for this wonderful plugin, my website has a lot of comments, several times the vps cpu reached 100% of use on the pages with many comments, this plugin is wonderful, excellent.

Отличный плагин!

By westgen on February 27, 2021

Спасибо за отличный плагин! Это то, что я искал.

Just what I needed

By janaa on October 2, 2020

Just what I needed, and it didn't slow down my webpages!

It's a ( JUNK ) killer, right off the bat.

By MrsJessicaSimpson on August 23, 2020

This plugin is brilliant, but for all the wrong reasons. Currently running WP - Version - 5.5 You all know the story, junk bomber-bots cruises the web, see an open comments section: then swoops in and drops their get rich (and other), foul smelling loads right into your unsuspecting core, whereby you have to clean the [spam] out, if the system hasn't already done so, but you still need to check it anyhow: just in case. It's a pain, am I right? The only viable solution that I've found to date, (apart from installing junk plugin killers that don't work), is to close off [all] comments on [all] pages bar one, the contacts page: that I had to monitor constantly, .. But not any more, if you select (Button) to load the comments section, then it appears that this Plugin hides the WP comments-open-letter-box from the bomber-bots, which is brilliant. Now I'm not saying that the junk-Bots can't evolve: they probably will, but currently, the automatic spam scripts can't press a button to open their bomb-bays with their stinking deposits, .. Oh' happy days: no junk mail for over a week now. I can highly recommend the lazy loading plugin, but as I say: for all the wrong reasons. Hope it helps.

Almost Great

By aapc on July 10, 2020

I work on a lot of sites that have a ton of comments so lazy loading seems like an interesting idea. Unfortunately I found this plugin breaks a very basic WP function of using an anchor to quickly scroll down to the comments section. Many themes have this "jump to comments" link built right in. Unfortunately both the "#respond" and "#comments" anchors are part of the HTML that gets lazy loaded. I hope the author comes up with a solution. Keep up the good work!

Straight-forward, effective solution

By cyborg88 on July 8, 2020

Although the plugin has not been updated for WP 5.4.2, it still works as documented. No bloat. A straight-forward solution. Kudos to the developer, although I hope the plugin has not been abandoned. Confirmed works with Genesis Framework.

Excellent

By AnndYi on June 12, 2020

Does what it says will do. Thanks.

2.0.1

  • Fixed comments not rendering on Genesis and similar classic themes that rely on comments_template() populating comments_by_type.

2.0.0

  • Complete rewrite using React and the WordPress REST API.
  • Added support for block themes (the core Comments block).
  • New React settings page under Comments Lazy Load.
  • Settings for load method, minimum comment count, button text, button style and loader visibility.
  • Per-post cache of the rendered comments block, with a “Clear comments cache” action in the settings.
  • Crawlers receive the inline comments by default so SEO is preserved.
  • Removed the dependency on jQuery.
  • Existing v1.x load-method setting is migrated automatically on upgrade.

1.0.10

  • Added compatibility for the Divi theme builder.
Back to top